Haskell LSP autocompletion not working
Summary
Openin a new or existing haskell file there is no completion from LSP instead there are constant error messages in the statusbar.
Reproduction Steps
I tried this:
- Creating a new haskell file
hx -vvv some.hs - Start typing e.g.
import XMon - Get error message
LSP: no handler for: STextDocumentDidChange\n"
I expected this to happen:
- Completion working normally
Instead, this happened:
3. Get error message LSP: no handler for: STextDocumentDidChange\n"
Helix log
~/.cache/helix/helix.log
2022-11-10T17:04:20.172 helix_lsp::transport [ERROR] err <- "No 'hie.yaml' found. Try to discover the project type!\n"
2022-11-10T17:04:20.174 helix_lsp::transport [ERROR] err <- "Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.8.0.0 x86_64 ghc-8.10.7\n"
2022-11-10T17:04:20.174 helix_lsp::transport [ERROR] err <- "Current directory: /home/eicke\n"
2022-11-10T17:04:20.174 helix_lsp::transport [ERROR] err <- "Operating system: linux\n"
2022-11-10T17:04:20.174 helix_lsp::transport [ERROR] err <- "Arguments: [\"--lsp\"]\n"
2022-11-10T17:04:20.174 helix_lsp::transport [ERROR] err <- "Cradle directory: /home/eicke\n"
2022-11-10T17:04:20.174 helix_lsp::transport [ERROR] err <- "Cradle type: Default\n"
2022-11-10T17:04:20.216 helix_lsp::transport [ERROR] err <- "\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "Tool versions found on the $PATH\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "cabal: 3.6.2.0\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "stack: 2.9.1\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "ghc: 9.2.5\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "\n"
2022-11-10T17:04:20.217 helix_lsp::transport [ERROR] err <- "Consulting the cradle to get project GHC version...\n"
2022-11-10T17:04:20.237 helix_lsp::transport [ERROR] err <- "Project GHC version: 9.2.5\n"
2022-11-10T17:04:20.237 helix_lsp::transport [ERROR] err <- "haskell-language-server exe candidates: [\"haskell-language-server-9.2.5\",\"haskell-language-server\"]\n"
2022-11-10T17:04:20.237 helix_lsp::transport [ERROR] err <- "Failed to find a HLS version for GHC 9.2.5\n"
2022-11-10T17:04:20.238 helix_lsp::transport [ERROR] err <- "Executable names we failed to find: haskell-language-server-9.2.5,haskell-language-server\n"
2022-11-10T17:04:20.238 helix_lsp::transport [ERROR] err <- " 2022-11-10T16:04:20.238095Z | Info | Starting server\n"
2022-11-10T17:04:20.238 helix_lsp::transport [INFO] <- {"method":"window/showMessageRequest","id":0,"params":{"message":"Failed to find a HLS version for GHC 9.2.5\nExecutable names we fai
led to find: haskell-language-server-9.2.5,haskell-language-server","type":1,"actions":[{"title":"Try to restart"}]},"jsonrpc":"2.0"}
2022-11-10T17:04:20.238 helix_term::application [ERROR] Language Server: Method not found window/showMessageRequest
2022-11-10T17:04:20.238 helix_lsp::transport [INFO] <- {"id":0,"result":{"capabilities":{"definitionProvider":false,"documentHighlightProvider":false,"callHierarchyProvider":false,"colorPr
ovider":false,"selectionRangeProvider":false,"foldingRangeProvider":false,"typeDefinitionProvider":false,"renameProvider":false,"documentSymbolProvider":false,"referencesProvider":false,"workspaceSymbolProvider":false,"codeActionProvider":false,"declarationProvider":false,"implementationProvider":false,"textDocumentSync":{"openClose":true,"save":{},"change":2},"semanticTokensProvider":{"legend":{"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"]}},"documentFormattingProvider":false,"documentRangeFormattingProvider":false,"hoverProvider":false,"workspace":{}}},"jsonrpc":"2.0"}
2022-11-10T17:04:20.238 helix_lsp::transport [INFO] <- {"capabilities":{"callHierarchyProvider":false,"codeActionProvider":false,"colorProvider":false,"declarationProvider":false,"definitionProvider":false,"documentFormattingProvider":false,"documentHighlightProvider":false,"documentRangeFormattingProvider":false,"documentSymbolProvider":false,"foldingRangeProvider":false,"hoverProvider":false,"implementationProvider":false,"referencesProvider":false,"renameProvider":false,"selectionRangeProvider":false,"semanticTokensProvider":{"legend":{"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"]}},"textDocumentSync":{"change":2,"openClose":true,"save":{}},"typeDefinitionProvider":false,"workspace":{},"workspaceSymbolProvider":false}}
2022-11-10T17:04:20.238 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-11-10T17:04:20.239 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"haskell","text":"\n","uri":"file:///home/eicke/some.hs","version":0}}}
2022-11-10T17:04:20.239 helix_lsp::transport [ERROR] err <- "2022-11-10T16:04:20.238983Z | Error | LSP: no handler for: SInitialized\n"
2022-11-10T17:04:20.239 helix_lsp::transport [ERROR] err <- "2022-11-10T16:04:20.239142Z | Error | LSP: no handler for: STextDocumentDidOpen\n"
2022-11-10T17:04:22.932 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"text":"i"}],"textDocument":{"uri":"file:///home/eicke/some.hs","version":1}}}
2022-11-10T17:04:22.932 helix_lsp::transport [ERROR] err <- "2022-11-10T16:04:22.932740Z | Error | LSP: no handler for: STextDocumentDidChange\n"
2022-11-10T17:04:23.988 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":1,"line":0},"start":{"character":1,"line":0}},"text":"m"}],"textDocument":{"uri":"file:///home/eicke/some.hs","version":2}}}
2022-11-10T17:04:23.988 helix_lsp::transport [ERROR] err <- "2022-11-10T16:04:23.988685Z | Error | LSP: no handler for: STextDocumentDidChange\n"
2022-11-10T17:04:24.390 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":2,"line":0},"textDocument":{"uri":"file:///home/eicke/some.hs"}},"id":1}
2022-11-10T17:04:24.391 helix_lsp::transport [INFO] <- {"id":1,"error":{"message":"lsp:no handler for: STextDocumentCompletion","code":-32601},"jsonrpc":"2.0"}
2022-11-10T17:04:24.391 helix_lsp::transport [ERROR] <- MethodNotFound: lsp:no handler for: STextDocumentCompletion
2022-11-10T17:04:24.391 helix_view::editor [ERROR] editor error: Async job failed: protocol error: MethodNotFound: lsp:no handler for: STextDocumentCompletion
2022-11-10T17:04:24.420 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":2,"line":0},"start":{"character":2,"line":0}},"text":"p"}],"textDocument":{"uri":"file:///home/eicke/some.hs","version":3}}}
2022-11-10T17:04:24.421 helix_lsp::transport [ERROR] err <- "2022-11-10T16:04:24.421127Z | Error | LSP: no handler for: STextDocumentDidChange\n"
2022-11-10T17:04:24.676 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":3,"line":0},"start":{"character":3,"line":0}},"text":"o"}],"textDocument":{"uri":"file:///home/eicke/some.hs","version":4}}}
Platform
Linux
Terminal Emulator
gnome-terminal
Helix Version
22.08.1-424-ge17ad272
This looks like an issue with your installation of HLS.
These lines are printed to the log by the language server (it is printing these to stderr):
Failed to find a HLS version for GHC 9.2.5
Executable names we failed to find: haskell-language-server-9.2.5,haskell-language-server
It looks like the wrapper is looking for HLS for GHC 9.2.5 but can't find it.
Hey Thanks for your response I'm Going to look into it
what server version are you using? judging by the release description hls 1.8.0.0 does not support ghc 9.2.5
I am a heavy Haskell user and I've never ran into this. I would check that you can build files with haskell-language-server foo/bar.hs in your terminal first.
I am a heavy Haskell user and I've never ran into this. I would check that you can build files with
haskell-language-server foo/bar.hsin your terminal first.
What version of hls do you use? ghc version? I have problems with 1.8.0.0 and helix editor, But 1.7.0.0 works fine.
❯ haskell-language-server --version
2022-12-02T15:03:33.360960Z | Info | No log file specified; using stderr.
haskell-language-server version: 1.8.0.0 (GHC: 9.2.4) (PATH: /nix/store/pz9px8s45b1hhxqaws2x92r56z65bdnr-haskell-language-server-exe-haskell-language-server-1.8.0.0/bin/haskell-language-server)
❯ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.2.4
I tried
stack new sandbox yesodweb/sqlite
cd sandbox
hx app/main.hs
but autocomplete and errors handling don't work here is helix log
2022-12-03T00:39:29.221 helix_lsp::transport [ERROR] err <- "Consulting the cradle to get project GHC version...\n"
2022-12-03T00:39:33.449 helix_lsp::transport [ERROR] err <- "Project GHC version: 9.0.2\n"
2022-12-03T00:39:33.449 helix_lsp::transport [ERROR] err <- "haskell-language-server exe candidates: [\"haskell-language-server-9.0.2\",\"haskell-language-server\"]\n"
2022-12-03T00:39:33.449 helix_lsp::transport [ERROR] err <- "Launching haskell-language-server exe at:/home/user/.ghcup/bin/haskell-language-server-9.0.2\n"
2022-12-03T00:39:47.512 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.507865Z | Info | No log file specified; using stderr.\n"
2022-12-03T00:39:47.516 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.511604Z | Info | haskell-language-server version: 1.8.0.0 (GHC: 9.0.2) (PATH: /home/user/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-9.0.2)\n"
2022-12-03T00:39:47.520 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.516704Z | Info | Directory: /home/user/haskell/sandbox\n"
2022-12-03T00:39:47.524 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.520230Z | Info | Starting (haskell-language-server) LSP server...\n"
2022-12-03T00:39:47.534 helix_lsp::transport [ERROR] err <- " GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}\n"
...
...
...
2022-12-03T00:39:47.553 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.550087Z | Info | Logging heap statistics every 60.00s\n"
2022-12-03T00:39:47.554 helix_lsp::transport [ERROR] err <- " 2022-12-02T19:39:47.554383Z | Info | Starting LSP server...\n"
2022-12-03T00:39:47.555 helix_lsp::transport [ERROR] err <- " If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!\n"
...
...
...
2022-12-03T00:39:47.558 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.557673Z | Info | Starting server\n"
2022-12-03T00:39:47.568 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:47.564195Z | Info | Started LSP server in 0.01s\n"
2022-12-03T00:39:49.093 helix_lsp [ERROR] failed to initialize language server: request timed out
2022-12-03T00:39:52.103 helix_lsp::transport [ERROR] err <- "2022-12-02T19:39:52.102817Z | Info | Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-4541841872169886298) \"file:///home/user/haskell/sandbox\"], clientSettings = hashed Nothing}\n"
2022-12-03T00:39:52.108 helix_lsp::transport [ERROR] Tried sending response into a closed channel (id=Num(0)), original request likely timed out
2022-12-03T00:40:47.613 helix_lsp::transport [ERROR] err <- "2022-12-02T19:40:47.613178Z | Info | Live bytes: 0.00MB Heap size: 0.00MB\n"
2022-12-03T00:41:47.673 helix_lsp::transport [ERROR] err <- "2022-12-02T19:41:47.672980Z | Info | Live bytes: 0.00MB Heap size: 0.00MB\n"
2022-12-03T00:42:47.733 helix_lsp::transport [ERROR] err <- "2022-12-02T19:42:47.732925Z | Info | Live bytes: 0.00MB Heap size: 0.00MB\n"
checking file from console works fine
haskell-language-server-9.0.2 app/main.hs
...
...
2022-12-02T19:56:05.938826Z | Info | Cradle path: app/main.hs
2022-12-02T19:56:05.940438Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for app/main.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2022-12-02T19:56:17.095645Z | Info | Interface files cache directory: /home/user/.cache/ghcide/main-254ec90838f9854db8b89776816f59ad03fe2b49
2022-12-02T19:56:17.097273Z | Info | Making new HscEnv. In-place unit ids: [main]
Completed (1 file worked, 0 files failed)
My problem is solving after adding system-ghc: true to stack.yaml. It is a bug of hls when stack project have ghc 9.0.2.
Reinstalling ghc/haskell language server fixed the issue for me. Going too close this issue
