Closed andys8 closed 3 years ago
Well hidden, we have that documented: https://github.com/haskell/haskell-language-server/tree/master/ghcide#limitations-to-multi-component-support
Essentially, if you want goto definition to work, you need to open a file from each component, e.g. open something from src/
in your editor as well, and it should start working!
Similar (or duplicate) of #799 and #486
It doesn't work for me, even if there is a file from src
open. See screenshot.
As I mentioned I'm currently also testing with the 6b6c405d14a29ab3d2e7dbb4e2f79229758d26ba which contains hiedb
. I can also test with different versions.
Is it working for you @fendor / @jneira with the example I posted and the same or a different hls version or different editor / environment?
I tested with a nearly vanilla setup of vscode with the hls extension. The behavior is the same, even though the target file is open.
I'm noticing this error. Any chance it has something to do with the issue or is it independent? (see Update)
{
"resource": "/home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/autogen/Paths_demo_hls_jump_to_definition.hs",
"owner": "Haskell (demo-haskell-language-server-jump-to-defintionion-issue)",
"severity": 8,
"message": "user error (Failed to get the immediate reverse dependencies of NormalizedFilePath \"/home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/autogen/Paths_demo_hls_jump_to_definition.hs\")",
"source": "compiler",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 2,
"endColumn": 1
}
I doubt the Paths_
error is the cause. With this workaround it can be removed/resolved, but the issue (not being able to jump to definition) is still the case.
With cabal
everything is fine (sorry for that pretty much useless info), e.g. goto definition works, etc...
With stack
I can reproduce the issue.
I'm glad the issue can be reproduced. Thanks @fendor for confirmation.
Now looking towards solving the issue: is the cause of the behavior known (looking at related issues @jneira linked)? Which component in the tool chain is the one to look at (hls, ghcide, hie-bios, stack)?
Wohoo. I think recent changes fixed the behavior. It is working with current master
(e2bf01bf4a3df67a2ada5544e4532c2f7f2f32a4).
It might be fixed by #1357 (fbb96e83e91e970e9c567fe51cbee306d3d66e4e) or #1358 (d87a5dbacdf8e11998f3f648d6beb57ae47736df) or another change. Thanks @wz1000
Will re-test this issue once a new version is released, too.
Closing this, because it looks very good.
Your environment
Output of
haskell-language-server --probe-tools
orhaskell-language-server-wrapper --probe-tools
:Which lsp-client do you use: coc.nvim version: 0.0.80-6e5a2aaeb5 Describe your project (alternative: link to the project): https://github.com/andys8/demo-haskell-language-server-jump-to-def-issue Contents of
hie.yaml
:Steps to reproduce
I created a demo project: https://github.com/andys8/demo-haskell-language-server-jump-to-def-issue The project setup is done with
stack new
and only slightly modified.test/Spec.hs
testHelper
workslibraryFunction
doesn't workThe workaround is to add
src
dir tosource-dirs
, but this has the downside of duplication and higher compile times.Expected behaviour
Jump to definition is working for
libraryFunction
/ dependencies.Actual behaviour
Jump to definition works only for
source-dirs
.Include debug information
Execute in the root of your project the command
haskell-language-server --debug .
and paste the logs here:Debug output:
``` (haskell-language-server)Ghcide setup tester in /home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue. Report bugs at https://github.com/haskell/haskell-language-server/issues Tool versions found on the $PATH cabal: 3.2.0.0 stack: 2.5.1 ghc: 8.8.3 Step 1/4: Finding files to test in /home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue Found 4 files Step 2/4: Looking for hie.yaml files that control setup Found 1 cradle Step 3/4: Initializing the IDE Step 4/4: Type checking the files [INFO] Consulting the cradle for "src/Lib.hs" [INFO] Using interface files cache dir: ghcide [INFO] Making new HscEnv[main] [INFO] Consulting the cradle for "test/SpecHelper.hs" [INFO] Using interface files cache dir: ghcide [INFO] Using interface files cache dir: ghcide [INFO] Making new HscEnv[main,main] [INFO] Consulting the cradle for "app/Main.hs" [INFO] Using interface files cache dir: ghcide [INFO] Using interface files cache dir: ghcide [INFO] Using interface files cache dir: ghcide [INFO] Making new HscEnv[main,main,main] File: /home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/demo-hls-jump-to-definition-test/autogen/Paths_demo_hls_jump_to_definition.hs Hidden: no Range: 1:1-2:1 Source: compiler Severity: DsError Message: [0;91muser error (Failed to get the immediate reverse dependencies of NormalizedFilePath "/home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/demo-hls-jump-to-definition-test/autogen/Paths_demo_hls_jump_to_definition.hs")[0m File: /home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/demo-hls-jump-to-definition-exe/autogen/Paths_demo_hls_jump_to_definition.hs Hidden: no Range: 1:1-2:1 Source: compiler Severity: DsError Message: [0;91muser error (Failed to get the immediate reverse dependencies of NormalizedFilePath "/home/andreas/dev/repository/demo-haskell-language-server-jump-to-defintionion-issue/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/demo-hls-jump-to-definition-exe/autogen/Paths_demo_hls_jump_to_definition.hs")[0m [INFO] finish: User TypeCheck (took 0.04s) Completed (4 files worked, 0 files failed) ```Paste the logs from the lsp-client, e.g. for VS Code
LSP logs:
``` ## versions vim version: VIM - Vi IMproved 8.2 8022347 node version: v14.9.0 coc.nvim version: 0.0.80-6e5a2aaeb5 coc.nvim directory: /home/andreas/.vim/plugged/coc.nvim term: dumb platform: linux ## Log of coc.nvim 2021-02-01T19:57:24.934 INFO (pid:3024769) [services] - registered service "languageserver.elmLS" 2021-02-01T19:57:24.936 INFO (pid:3024769) [services] - registered service "languageserver.haskell-language-server" 2021-02-01T19:57:24.936 INFO (pid:3024769) [services] - registered service "languageserver.bash" 2021-02-01T19:57:24.936 INFO (pid:3024769) [services] - registered service "languageserver.dockerfile" 2021-02-01T19:57:24.936 INFO (pid:3024769) [services] - registered service "languageserver.purescript" 2021-02-01T19:57:24.977 INFO (pid:3024769) [services] - registered service "diagnostic-languageserver" 2021-02-01T19:57:25.137 INFO (pid:3024769) [plugin] - coc.nvim 0.0.80-6e5a2aaeb5 initialized with node: v14.9.0 after 267ms 2021-02-01T19:57:25.143 INFO (pid:3024769) [language-client-index] - cSpell started with 3024780 2021-02-01T19:57:26.447 INFO (pid:3024769) [attach] - receive notification: doAutocmd [ 1 ] 2021-02-01T19:57:26.492 INFO (pid:3024769) [attach] - receive notification: doAutocmd [ 1 ] 2021-02-01T19:57:26.553 INFO (pid:3024769) [services] - haskell-language-server state change: stopped => starting 2021-02-01T19:57:26.554 INFO (pid:3024769) [services] - diagnostic language service state change: stopped => starting 2021-02-01T19:57:26.562 INFO (pid:3024769) [language-client-index] - Language server "languageserver.haskell-language-server" started with 3024838 2021-02-01T19:57:26.568 INFO (pid:3024769) [language-client-index] - diagnostic-languageserver started with 3024843 2021-02-01T19:57:26.685 INFO (pid:3024769) [services] - diagnostic language service state change: starting => running 2021-02-01T19:57:26.685 INFO (pid:3024769) [services] - service diagnostic-languageserver started 2021-02-01T19:57:27.427 INFO (pid:3024769) [services] - haskell-language-server state change: starting => running 2021-02-01T19:57:27.430 INFO (pid:3024769) [services] - service languageserver.haskell-language-server started 2021-02-01T19:57:27.863 INFO (pid:3024769) [attach] - receive notification: jumpDefinition [] 2021-02-01T19:57:27.894 INFO (pid:3024769) [attach] - receive notification: doAutocmd [ 1 ] 2021-02-01T19:57:28.565 INFO (pid:3024769) [attach] - receive notification: doAutocmd [ 1 ] 2021-02-01T19:57:29.180 INFO (pid:3024769) [attach] - receive notification: jumpDefinition [] 2021-02-01T19:57:34.132 INFO (pid:3024769) [attach] - receive notification: showInfo [] ```