Currently, language servers seem to be started in whatever directory neovim is running in, rather than in either the working directory of the neovim buffer or the project root.
Some language servers (I'm thinking of hie) need to run in the project root. It would be nice if LanguageClient-neovim could use the logic it already has in place for detecting the project root to decide what directory it starts the server in.
I was able to get it to work correctly after adding this to my config
let g:LanguageClient_rootMarkers = {
\ 'haskell': ['*.cabal']
\ }
Just to clarify, I think @purefn might be solving a different problem (sorry if I'm missing something). The issue I'm concerned with is not that LanguageClient-neovim doesn't find the root of haskell projects. That problem is solved by @purefn's suggestion, and doesn't arise for projects that are being tracked in git.
What I'm concerned with is that the hie process is not necessarily started in the root directory that LanguageClient-neovim detects. It's started in whatever directory nvim was started in. So, if you didn't start nvim in the root of your project, the you need to set the root manually with the -r flag if you want, e.g. hie-wrapper to correctly detect the ghc version.
@gleachkr do you know a workaround that can be used now for hie-wrapper?
For me, it works to start nvim in the directory where your project lives. Alternatively, within nvim, you can cd to that directory and then call
function! InitHie()
let g:LanguageClient_serverCommands = {
\ 'haskell': ['hie-wrapper', '--lsp', '-r', getcwd()],
\ }
LanguageClientStart
endfunction
@autozimu any movement on this?
Most helpful comment
For me, it works to start nvim in the directory where your project lives. Alternatively, within nvim, you can
cdto that directory and then call