Closed Tyrn closed 5 months ago
Weird, I personally also use nvim, and this single line of config has been sufficient to get HLS working. Let's start by checking if HLS works in isolation. Can you do a new checkout and tell me what happens if you run haskell-language-server
? For reference, this is what it looks like for me:
$ cp -r template-haskell hls-test
$ cd hls-test/
$ ./wizard.sh
...
All set!
$ nix develop
nix-shell$ haskell-language-server
2024-03-04T12:42:04.376306Z | Info | haskell-language-server version: 2.4.0.0 (GHC: 9.4.8) (PATH: /nix/store/ycy6k3p91s6w4nvidhm9rb2inmmy342l-haskell-language-server-2.4.0.0/bin/.haskell-language-server-9.4.8-unwrapped)
2024-03-04T12:42:04.377005Z | Info | Directory: /home/jmc/Dev/hls-test
2024-03-04T12:42:04.377180Z | Info | Logging heap statistics every 60.00s
ghcide setup tester in /home/jmc/Dev/hls-test.
Report bugs at https://github.com/haskell/haskell-language-server/issues
Step 1/4: Finding files to test in /home/jmc/Dev/hls-test
Found 4 files
Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
(/home/jmc/Dev/hls-test/hie.yaml)
Step 3/4: Initializing the IDE
Step 4/4: Type checking the files
...
Files that failed:
* /home/jmc/Dev/hls-test/bench/Main.hs
Completed (3 files worked, 1 file failed)
The error is curious: what does GHCup (nuked) have to do with all this?
master ~/spaces/haskell/hello> nix develop
[alexey@gaucho hello]$ haskell-language-server
[ Error ] [GHCup-00130] The version 9.4.8 of the tool ghc is not installed.
2024-03-04T13:01:26.907473Z | Info | haskell-language-server version: 2.4.0.0 (GHC: 9.4.8) (PATH: /nix/store/ycy6k3p91s6w4nvidhm9rb2inmmy342l-haskell-language-server-2.4.0.0/bin/.haskell-language-server-9.4.8-unwrapped)
2024-03-04T13:01:26.910617Z | Info | Directory: /home/alexey/spaces/haskell/hello
2024-03-04T13:01:26.911025Z | Info | Logging heap statistics every 60.00s
ghcide setup tester in /home/alexey/spaces/haskell/hello.
Report bugs at https://github.com/haskell/haskell-language-server/issues
Step 1/4: Finding files to test in /home/alexey/spaces/haskell/hello
Found 4 files
Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
(/home/alexey/spaces/haskell/hello/hie.yaml)
Step 3/4: Initializing the IDE
Step 4/4: Type checking the files
2024-03-04T13:01:26.966824Z | Info | Cradle path: src/Lib.hs
2024-03-04T13:01:26.977092Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2024-03-04T13:01:35.151628Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/hello-0-inplace-a48c489d61f7eae3537e576d0a14f124b80e85a6
2024-03-04T13:01:35.153651Z | Info | Making new HscEnv. In-place unit ids: [hello-0-inplace]
2024-03-04T13:01:35.403397Z | Info | Cradle path: bench/Main.hs
2024-03-04T13:01:35.404184Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2024-03-04T13:02:26.966279Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:03:27.026768Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:04:27.037265Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:05:27.102369Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:06:27.162425Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:07:27.208813Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:08:27.257299Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:09:27.316441Z | Info | Live bytes: 28.43MB Heap size: 176.16MB
2024-03-04T13:09:52.012494Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/main-50513754f7cdf8924915106b285d7be5fd64fb85-50513754f7cdf8924915106b285d7be5fd64fb85
2024-03-04T13:09:52.013078Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/hello-0-inplace-50513754f7cdf8924915106b285d7be5fd64fb85
2024-03-04T13:09:52.013358Z | Info | Making new HscEnv. In-place unit ids: [ main-50513754f7cdf8924915106b285d7be5fd64fb85
, hello-0-inplace ]
2024-03-04T13:09:52.121132Z | Info | Cradle path: test/Spec.hs
2024-03-04T13:09:52.122035Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2024-03-04T13:09:55.418341Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/main-71bb2752c559b5208438966785fe267e729e515b-71bb2752c559b5208438966785fe267e729e515b
2024-03-04T13:09:55.418893Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/main-50513754f7cdf8924915106b285d7be5fd64fb85-71bb2752c559b5208438966785fe267e729e515b
2024-03-04T13:09:55.419155Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/hello-0-inplace-71bb2752c559b5208438966785fe267e729e515b
2024-03-04T13:09:55.419407Z | Info | Making new HscEnv. In-place unit ids: [ main-71bb2752c559b5208438966785fe267e729e515b
, main-50513754f7cdf8924915106b285d7be5fd64fb85
, hello-0-inplace ]
2024-03-04T13:09:55.844433Z | Info | Cradle path: app/Main.hs
2024-03-04T13:09:55.845004Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2024-03-04T13:09:59.083184Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/main-7a4d1ff30b4de94a399e4bc57bfd96d081ff14d0-7a4d1ff30b4de94a399e4bc57bfd96d081ff14d0
2024-03-04T13:09:59.083780Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/main-71bb2752c559b5208438966785fe267e729e515b-7a4d1ff30b4de94a399e4bc57bfd96d081ff14d0
2024-03-04T13:09:59.084054Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/main-50513754f7cdf8924915106b285d7be5fd64fb85-7a4d1ff30b4de94a399e4bc57bfd96d081ff14d0
2024-03-04T13:09:59.084272Z | Info | Interface files cache directory: /home/alexey/.cache/ghcide/hello-0-inplace-7a4d1ff30b4de94a399e4bc57bfd96d081ff14d0
2024-03-04T13:09:59.084450Z | Info | Making new HscEnv. In-place unit ids: [ main-7a4d1ff30b4de94a399e4bc57bfd96d081ff14d0
, main-71bb2752c559b5208438966785fe267e729e515b
, main-50513754f7cdf8924915106b285d7be5fd64fb85
, hello-0-inplace ]
2024-03-04T13:09:59.748031Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File: /home/alexey/spaces/haskell/hello/bench/Main.hs
Hidden: no
Range: 1:1-1:11
Source: typecheck
Severity: DiagnosticSeverity_Warning
Message:
The import of ‘Lib’ is redundant
except perhaps to import instances from ‘Lib’
To import instances alone, use: import Lib()
2024-03-04T13:09:59.748376Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File: /home/alexey/spaces/haskell/hello/app/Main.hs
Hidden: no
Range: 1:1-1:11
Source: typecheck
Severity: DiagnosticSeverity_Warning
Message:
The import of ‘Lib’ is redundant
except perhaps to import instances from ‘Lib’
To import instances alone, use: import Lib()
Completed (4 files worked, 0 files failed)
I'm not sure, maybe there's some vestigial ghcup stuff in your $PATH? What OS are you on?
Either way, it seems like your HLS works fine, so my guess would be nvim is not picking it up correctly.
What's your :LspInfo
output after you open a Haskell file? Mine is
Press q or <Esc> to close this window. Press <Tab> to view server doc.
Language client log: /home/jmc/.local/state/nvim/lsp.log
Detected filetype: haskell
1 client(s) attached to this buffer:
Client: hls (id: 1, bufnr: [1])
filetypes: haskell, lhaskell
autostart: true
root directory: /home/jmc/Dev/hls-test
cmd: /nix/store/ycy6k3p91s6w4nvidhm9rb2inmmy342l-haskell-language-server-2.4.0.0/bin/haskell-language-server-wrapper --lsp
version: haskell-language-server version: 2.4.0.0 (GHC: 9.4.8) (PATH: /nix/store/ycy6k3p91s6w4nvidhm9rb2inmmy342l-haskell-language-server-2.4.0.0/bin/haskell-language-server-wrapper)
Configured servers list: nil_ls, hls, ccls, bashls, rust_analyzer, pyright, ruff_lsp
My OS is Manjaro (Arch family). I've got two boxes with similar installation. On one I use GHCup, and HLS just works. :LspInfo
shows haskell-language-server-wrapper
with options, indeed.
Language client log: /home/alexey/.local/state/nvim/lsp.log
Detected filetype: haskell
1 client(s) attached to this buffer:
Client: haskell-tools.nvim (id: 1, bufnr: [1])
filetypes: haskell, lhaskell
autostart: false
root directory: /home/alexey/spaces/haskell/hello
cmd: haskell-language-server-wrapper --lsp --logfile /tmp/nvim.alexey/0COSyM/0-haskell-language-server.log
Configured servers list: pyright, kotlin_language_server, yamlls, jsonls, taplo, elmls, lua_ls
On another box GHCup removed, nix develop
on template-haskell
. :LspInfo
shows no signs of the language server; there's log:
...
[START][2024-03-04 21:40:13] LSP logging initiated
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" 'Found "/home/alexey/spaces/haskell/hello/hie.yaml" for "/home/alexey/sp'
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" 'aces/haskell/hello/a"\n'
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "Run "
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "entered for haskell-language-server-wrapper(has"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "kell-language-server-wrapper) V"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "ersion 2.5.0.0 x86_64 ghc-9.2.8\nCurrent directory: /home/alexey/spaces"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "/haskell/hello\nOperati"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "ng system: linux\nArguments"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" ': ["--lsp","'
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" '--logfile","/tmp/nix-shel'
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "l.6RMxjF"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "/nvim.al"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "exey/Jqi"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "Q7H/0-ha"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "skell-"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "language"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "-server."
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" 'log"]\nCradle d'
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "irectory"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" ": /home/al"
[ERROR][2024-03-04 21:40:13] .../vim/lsp/rpc.lua:734 "rpc" "haskell-language-server-wrapper" "stderr" "exey/sp"
...
The log is much longer. No vestigial stuff from GHCup on my $PATH, checked.
Mine says Client: hls (id: 1, bufnr: [1])
, but yours says Client: haskell-tools.nvim (id: 1, bufnr: [1])
. I'm not familiar with haskell-tools, but it might be trying to be clever about finding your HLS binary and somehow bypass the intended one from the local shell. A cursory browse suggests that https://github.com/mrcjkb/haskell-tools.nvim/issues/200 is people having a similar issue.
Thank you very much for your effort above and beyond the call of duty!
I'm thinking what my next step should be. I don't use NixOS, so I can't just appropriate your config :) . AstroNvim served me wonderfully, neither breaking beyond hope nor requiring profound expertise. There's no such thing as a free lunch, unfortunately.
Right now I'm stuck with the so-called Astrocommunity Pack for Haskell. This means that I can't even edit it. The remaining option is to create something like ~/.config/nvim/lua/user/plugins/haskell.lua
on my own, without the use of haskell-tools
. It's just as easy as with any Neovim installation, if not easier—provided you know what you're doing...
Any suggestion or link is welcome.
First step: moved the init.lua from the Astrocommunity Haskell Pack (already removed from my config) to ~/.config/nvim/lua/user/plugins/haskell.lua
. Still works, not a character changed. Almost too good to be true. Great engineering, AstroNvim. Now I can do with it (init.lua, now ~/.config/nvim/lua/user/plugins/haskell.lua
) whatever I please. If I only knew how to get rid of haskell-tools
.
(going to assume this is completed)
Hi,
Previously I used GHCup and AstroNvim (Neovim). HLS worked uneventfully. Now I've been trying
template-haskell
and it doesn't seem to work. All I can tell, that the necessary packages are present:What else should I check?