Setting up Haskell development environment for Neovim (2022)
Written 3 years ago
This is mostly for my sake in case I need it again but may help others avoid the pitfalls I faced, so sharing here.
In shell (I’m on Manjaro Linux)
Do NOT install stack, cabal, ghc, ghci, ghcid and what have you separately.
-
Install ghcup yay -S ghcup-hs-bin
, check this link haskell.org/ghcup for other platforms.
-
Install ghc, stack and cabal using ghcup tui
. DO NOT INSTALL HLS YET!
-
[I]nstall recommended versions. Make sure hls supports that version here.
-
[S]et them as default. ghc
, stack
, and cabal
should be available on path.
Note: one tick = installed, another tick = default
In neovim
I’m using built-in LSP along with nvim-lsp-installer plugin for convenience. Check this file full setup.
-
Open a temp.hs
file
-
:LspInstallInfo
should show a green hls
available
-
[I]nstall, drink your coffee, close and reopen file.
-
Profit!
Some plugin links to avoid lots of googling:
nvim-lspconfig
nvim-lsp-installer
nvim-cmp
Yes these simple steps took me almost a day of stumbling around. Hopefully, next time it’ll be done in minutes.