Experiences after installing Haskell language server
I followed the instructions to install the haskell-language-server from their Readme.md.
I tried various ways to install it and eventually the stack installation -method worked. After half a hour of compiling I finally got it to work. It told me that gchide was compiled against 8.8.4 and I was currently running 8.0.2.
Unable to install haskell-language-server for 8.0.2, I ended up installing 8.8.4.
..it installed Haskell language server along it. Ok.
Installation of Vim plugins
I expect that when I install a Vim plugin, I can do it through pathogen. LanguageClient-neovim seemed to allow this, but also had errors on the startup because it wanted me to run an install.sh -script that installs something along it.
cd .vim/bundle
git clone --depth 1 https://github.com/autozimu/LanguageClient-neovim.git
cd LanguageClient-neovim
bash install.sh
Then I had to configure haskell language server in the ~/.vimrc
:
set rtp+=~/.vim/bundle/LanguageClient-neovim
let g:LanguageClient_serverCommands = { 'haskell': ['haskell-language-server-wrapper', '--lsp'] }
" stops the gitgutter column from popping in/out by hiding it entirely.
let g:LanguageClient_diagnosticsSignsMax=0
I tried to get codeLens to work because it provides additional functionality, but I found out it doesn't work on Vim8.
All of the other features are working.
It's working great
I really like this language server, especially these three commands.
autocmd FileType haskell nmap <buffer> <silent> <LocalLeader>e :call LanguageClient#explainErrorAtPoint()<CR>
autocmd FileType haskell nmap <buffer> <silent> <LocalLeader>h :call LanguageClient#textDocument_hover()<CR>
autocmd FileType haskell nmap <buffer> <silent> <LocalLeader>g :call LanguageClient#textDocument_definition()<CR>
I've mapped the local leader letter to a comma and it's right under my finger. To illustrate why this is so interesting, lets show a thing. I want to expand directories to their subdirectories.
expandDirectories :: [FilePath] -> IO [FilePath]
expandDirectories = _
When I press the explain-command on the underscore, I can immediately see what the context there is.
_ :: [FilePath] -> IO [FilePath]
Next if I substitute in mapM _
, I get this:
_ :: FilePath -> IO FilePath
The initial impressions I have is that this thing responds fast. You get immediate feedback on what's wrong in the code. It also helps that you can use omnicomplete -feature to quickly peek into the documentation, even for the libraries you've installed project-local.
I've had concerns that the LSP would not suit functional programming languages because the optimal language services for Haskell are definitely different from optimal services for Java or C#, but I see the pieces that work for both do work there hard!
The Haskell language server is definitely making programming more smooth by reducing roundtrips outside to the terminal or the browser.