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:
However, I often find that if I try to Go To Definition
VSCode reports that no definition is found:
For many of these symbols I find that if I hover my cursor over the symbol I'm shown where the symbol is defined:
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?
I use
emacs
withinNixOS
, and I find that definitions are only found when they’re within the project I’m working on. Sometimes if I’m insrc
and the definition is inlib
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.