I’m wondering how to make HLS show the warnings that you would get from compiling a file with {-# OPTIONS_GHC -W #-} at the top, without adding that header to every file in my project.
I’m relatively new to Haskell and am not using Stack/Cabal because I’m not using any external dependencies. I just have a few modules in files.
You can create a hie.yaml file in your directory, listing the exact GHC arguments you want your modules to be compiled with, see GitHub - haskell/hie-bios: Set up a GHC API session for various Haskell Projects
Note, the documentation currently misses the fact, you have to explicitly list all modules you want to compile, even though GHC would succeed without you listing each module individually.
Right, that’s the best approach imho; however, the post mentions they don’t use either stack or cabal, so this isn’t an option in this particular case, afaict.
After using the hie.yaml, my IDE (now) shows warnings for things like redundant imports that wouldn’t trigger warnings. However ghcide doesn’t show anything.
Are you really using ghcide? Or do you mean haskell-language-server? Ah, you mean ghcid. Be careful with names because ghcide is the engine of haskell-language-server, something entirely different to ghcid
I have trouble parsing that sentence, the IDE (which is HLS, right?) shows the warning, but you don’t expect these warnings in ghcid? That makes sense, the hie.yaml is only parsed by haskell-language-server. I think you’d have to specify the same warnings for your ghcid invocation, e.g. ghcid -c 'ghci -W Main'
There is currently no way to easily feed the flags from hie.yaml to ghcid directly, since that’s kind of a rare use-case.