Skip to content

Jump to definition for src not working if defined as library #1286

Closed
@andys8

Description

@andys8

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 0.9.0.0 (GHC: 8.8.3) (PATH: /home/andreas/.local/bin/haskell-language-server-wrapper) (GIT hash: 6b6c405d14a29ab3d2e7dbb4e2f79229758d26ba)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.8.3

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:

cradle:
  stack:
    - path: "./app"
      component: "demo-hls-jump-to-definition:exe:demo-hls-jump-to-definition-exe"
    - path: "./test"
      component: "demo-hls-jump-to-definition:test:demo-hls-jump-to-definition-test"
    - path: "./src"
      component: "demo-hls-jump-to-definition:lib"

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.

  • Open test/Spec.hs
  • Jump to def with testHelper works
  • Jump to def with libraryFunction doesn't work

The workaround is to add src dir to source-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 []

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcidetype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions