haskell / haskell-language-server

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

Spurious errors from extra-project Haskell files. #1703

Open friedbrice opened 3 years ago

friedbrice commented 3 years ago

I have some Haskell files in my project directory outside of the traditional ./src/, ./app/ and ./test/ directories. Examples are ./dev-tools.hs where I keep some things I like to use in GHCi, and ./.cache/hie-bios/.../Paths_mwb.hs.

Haskell plugin reports errors in these files and tries to set up a multi-cradle project, but I would prefer if it didn't since they are not part of my actual project source.

Is there a way to tell the plugin to only trigger for Haskell files in specific directories?

ilyakooo0 commented 3 years ago

I think defining an explicit hie.yaml will restrict HLS to the specified directories.

ilyakooo0 commented 3 years ago

This might be helpful for generating the file: https://github.com/Avi-D-coder/implicit-hie

friedbrice commented 3 years ago

Thanks, @ilyakooo0! I actually tried this, following the advice on their readme (https://github.com/mpickering/hie-bios#ignoring-directories-1).

My config looked like this:

cradle:
  multi:
    - path: "./.cache"
      config:
        cradle:
          none:
    - path: "./"
      config:
        cradle:
          cabal:
            - path: "./src"
              component: ...
            - path: "./app"
              component: ...
            - path: "./test"
              component: ...

(The ...s above are metasyntactic, as the true values there are incidental to the discussion.)

Unfortunately, when I closed and restarted VS Code, vscode-haskell complained that it could not determine the appropriate GHC version :-/

friedbrice commented 3 years ago

Oh, I am a fool! That error is being reported in ~/.config/... not in <project_root>/.config/.... Maybe this is a different problem, then. I get build errors and Multi Cradle errors reported from my Paths_<project_name>.hs files.

friedbrice commented 3 years ago

This is what I'm seeing every time I open my project:

Screen Shot 2021-04-09 at 1 00 30 PM

Here are my config files:

cradle:
 cabal:
  - path: "./src"
    component: ...
  - path: "./test"
    component: ...
  - path: "./app"
    component: ...
  - path: "./one-off-task"
    component: ...
{
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "editor.tabSize": 2,
  "haskell.formattingProvider": "ormolu",
  "haskell.formatOnImportOn": true,
  "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
}
jneira commented 3 years ago

hi, thanks for the bug report, maybe delete the cache mentioned in the error could help

fendor commented 3 years ago

Did you try opening the Paths_ module? That might produce such errors. (So the suggestion would be, to not do that :) )

I failed to reproduce the issue manually, can you maybe share a project or a minimal example?