elm-language-server: Erratic/broken behavior with Neovim's integrated LSP client
Expected Behavior
Normal LSP operation.
Current Behavior
When using elm-language-server with Neovim’s built-in language client (configured via nvim-lspconfig), elm-language-server’s parser appears to be completely broken. I’ve recorded two screencasts demonstrating some of the erratic behavior. A summary follows:
On opening a new buffer, LSP behaves fairly normally (type checking works, diagnostics make sense, whatever). After a couple normal editing operations (delete some text, add some text), it appears elm-language-server’s internal model of the buffer contents becomes totally malformed, and elm-language-server starts complaining about random, bogus parsing errors & spitting out nonsense diagnostics. Here are some sample error messages it gives:
No definition found for 'mport '.Parsing error.(on what should be totally valid Elm code)Could not find a module to import named 'String ' in…Unused pattern variable '='A value named 'nt' is already defined(in code that does not define anynt, only usesIntin a type signature).
Possible Solution
Sorry, but I have no familiarity with the internal workings of elm-language-server or Neovim LSP, so I honestly have no idea where to start suggesting fixes. A few observations nonetheless:
- This issue does not occur if I use coc.nvim instead of Neovim’s built-in LSP client, on the same elm-language-server installation.
- My other language servers (e.g. TypeScript, Python, OCaml) have been working fine with Neovim’s built-in LSP client. My point is that it’s possible that the error is on Neovim’s side, seeing as their LSP implementation is still “nightly”, but since I’ve only been able to reproduce the problem in the unique combination of Neovim + ElmLS, I don’t know how to isolate the problem.
Steps to Reproduce (for bugs)
- Set up elm-language-server with Neovim’s built-in LSP client. Follow instructions to install vim-plug, then contents of
~/.config/init.vim:call plug#begin() Plug 'neovim/nvim-lspconfig' call plug#end() lua << EOF require'lspconfig'.elmls.setup{} EOF - Edit literally any Elm file within a project.
- Make some random changes.
I have made screencasts illustrating this process here and here, showing the erratic errors that pop up for me.
Context
How has this issue affected you? What are you trying to accomplish? Ha ha, you’re funny.
Your Environment
- Version used: 2.0.2
- Editor used: Neovim, with built-in LSP
- Environment name and version (e.g. node.js 5.4): Node 14.15.4
- Operating System and version: Void Linux
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 18 (6 by maintainers)
I don’t believe this is solely related incremental synchronization, @razzeee. I’m using Helix and seeing this erratic behaviour fairly often. Not all the time, but it happens every time I sit down and code Elm. All changes are reported using incremental synchronization.
Video of me making some edits and saving the file, triggering a formatting request. https://asciinema.org/a/dexV5nWbBn5sQ9iDRD5X2r9qB and here’s the associated log.
Vide of me making some edits and saving the file. Then manually triggering formatting. https://asciinema.org/a/Bh47XkiludVBgxK6U8b5LuJal and here’s the associated log.
In both examples I get the same parsing error reported from the server. In both videos, it’s after formatting takes place.
We do technically support incremental buffer updates, it’s just disabled by default. @kwshi you can try enabling it to see if it fixes your problem.
I have this issue using coc.nvim, but it only happens when there are no real error messages.
I’ll just enable incremental sync by default for elmls client-side in nvim-lspconfig
@Razzeee Thanks for pointing this out