Open rmullin7286 opened 3 months ago
Hi, thank you for your bug report!
An even bigger thank you for this awesome analysis! Since you have identified the issue so accurately, would you be up for fixing this issue? If you get stuck, feel free to ping me here or on matrix.
Personally, I think we have to escape $
when the CompletionItem
is a Snippet
. So (1) is a must-have either way. Your suggestion (2) is a nice cherry-on-top afaict, which I am not opposed to.
Your environment
Which OS do you use?
MacOS and Arch Linux, the issue appears on both.
Which version of GHC do you use and how did you install it?
GHC 9.10.1 using ghcup
How is your project built (alternative: link to the project)? My main reproduction case is a simple haskell script with embedded cabal metadata:
However, the issue also appears in full cabal projects.
Which LSP client (editor/plugin) do you use?
neovim 0.10.0 using the haskell-tools plugin, lsp-config and nvim-cmp. My configuration can be found here.
Which version of HLS do you use and how did you install it?
HLS 2.9.0.1 using ghcup
Have you configured HLS in any way (especially: a
hie.yaml
file)? NoSteps to reproduce
Expected behaviour
Autocompletion should work correctly
Actual behaviour
At some point, every time a character is typed, the following error message appears:
Debug information
I've spent a bit of time diving into this issue and I think I understand what the root cause is. There's a few components at work:
$!
$!
is a standard operator in Haskell, I began to suspect that the issue is actually coming from HLSSo HLS is responding with a completion item of kind Snippet, and with an insertText of "$!".
It appears that the language server hardcodes every response to be of kind Snippet, and does not use PlainText responses, except in the case that snippets are disabled or the symbol being types is infix (e.g.
foo `on` bar
).There's two potential solutions here:
Currently the only workaround is to disable snippets in the language server, or role back to a version of nvim-cmp that doesn't perform validation, otherwise the functionality will be broken. The following code in init.lua should work as a temporary fix: