haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 367 forks source link

Detect stack elsewhere than the project root #1763

Open kendfrey opened 3 years ago

kendfrey commented 3 years ago

My project structure is such that my Haskell app is in a subfolder and not the project root. For example:

my-haskell-app/stack.yaml
my-haskell-app/package.yaml
my-haskell-app/src/etc...
README.md
etc...

When I open vscode to my project root I get a message like this:

haskell-language-server 0.7.1 for GHC 8.4.3 is not available on Windows_NT

From what I can tell, it's trying to use the system GHC installation instead of stack. Opening the subfolder my-haskell-app in vscode gets it to download the correct version of haskell-language-server.

The Haskell extension should work with stack projects that are not directly in vscode's workspace root directory.

fendor commented 3 years ago

This is not easily possible, since we need to launch the correct HLS version before a real Haskell file is opened. And the correct HLS version needs to know which ghc version you are using on the project, to launch a HLS version that has been compiled with the same ghc version.

A quick work-around is to add a top-level stack.yaml file, e.g.

resolver: ... # Not sure if required
packages: ./my-haskell-app

with which we can detect the right tool.

jneira commented 3 years ago

@kendfrey have you got the opportunity of trying the suggested workaround?

kendfrey commented 3 years ago

@kendfrey have you got the opprtunity of try the suggested workaround?

No I haven't used that workaround.