VScode Haskell Go To Definition doesn't work for some symbols

927 Views Asked by At

I'm getting started with Haskell and VSCode. I've forked and downloaded a repo with Haskell code. I've followed instructions for setting up a nix-shell correctly for this repo. I can successfully invoke cabal build and haskell-language-server for week 1 examples.

I've started up VSCode from within nix-shell and I can see that the language server is reporting symbol information to VSCode. For example:

enter image description here

However, I often find that if I try to Go To Definition VSCode reports that no definition is found:

enter image description here

For many of these symbols I find that if I hover my cursor over the symbol I'm shown where the symbol is defined:

enter image description here

Othertimes, I find that Go To Definition correctly resolves. For example, AuctionSchema on this line resolves correctly, while AuctionSchema on this line does not.

Why does Go To Definition only sometimes work? Is there a way to fix this?

1

There are 1 best solutions below

1
On

I use emacs within NixOS, and I find that definitions are only found when they’re within the project I’m working on. Sometimes if I’m in src and the definition is in lib it won’t find it either. I just assumed that Haskell Language Server cannot use Cabal or Hpack to find definitions, but only follows types within the directory branch the current source resides. Yep, that’s annoying, but it seems to be what’s currently on offer.