haskell-tools.nvim
haskell-tools.nvim copied to clipboard
HtProjectHelpers.get_package_name should read from stack.yaml instead of inferring from project directory name
Neovim version (nvim -v)
0.9.5
Operating system/version
Arch
Output of :checkhealth haskell-tools
==============================================================================
haskell-tools: require("haskell-tools.health").check()
Checking for Lua dependencies ~
- OK [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) installed.
Checking external dependencies ~
- OK haskell-language-server: found haskell-language-server version: 2.5.0.0 (GHC: 9.2.8) (PATH: /home/gabriel/.ghcup/hls/2.5.0.0/lib/haskell-language-server-2.5.0.0/bin/haskell-language-server-wrapper)
- WARNING hoogle: not found.
Install [ndmitchell/hoogle](https://github.com/ndmitchell/hoogle) for extended capabilities.
Recommended for better Hoogle search performance.
Without a local installation, the web API will be used by default.
Required if the hoogle mode is set to "telescope-local".
- WARNING fast-tags: not found.
Install [fast-tags](https://hackage.haskell.org/package/fast-tags) for extended capabilities.
Optional, for generating tags as a `tagfunc` fallback.
- OK curl: found curl 8.6.0 (x86_64-pc-linux-gnu) libcurl/8.6.0 OpenSSL/3.2.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 libssh2/1.11.0 nghttp2/1.59.0
- WARNING haskell-debug-adapter: not found.
Install [haskell-debug-adapter](https://github.com/phoityne/haskell-debug-adapter) for extended capabilities.
Optional, for `dap` support.
- WARNING ghci-dap: not found.
Install [ghci-dap](https://github.com/phoityne/ghci-dap) for extended capabilities.
Optional, for `dap` support.
Checking config ~
- OK No errors found in config.
Checking for conflicting plugins ~
- OK No conflicting plugins detected.
How to reproduce the issue
Opening the REPL :HtReplToggle will fail to import a project in case the project's directory does not match the package name in stack.yaml. The plugin will execute stack ghci <DIRECTORY_NAME> instead of stack ghci <PROJECT_NAME> and stack will error:
Warning: Some targets (<DIRECTORY_NAME>) are not local packages, and so cannot be directly loaded. In future versions of Stack, this might be supported - see https://github.com/commercialhaskell/stack/issues/1441 . It can still be useful to specify these, as they will be passed to ghci via -package flags.
Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
You are using snapshot: lts-21.25
If you want to use package hiding and options, then you can try one of the following:
* If you want to start a different project configuration than <DIRECTORY>/stack.yaml, then you can use stack init to create a new stack.yaml for the packages in the current directory.
* If you want to use the project configuration at <DIRECTORY>/stack.yaml, then you can add to its 'packages' field.
Expected behaviour
stach ghci <PROJECT_NAME> is called.
Actual behaviour
stack ghci <DIRECTORY_NAME> is called.
Log files
No response
The minimal config used to reproduce this issue.
default config
Hey 👋
Thanks for reporting. Some notes from myself:
- We'll have to handle both package.yaml and
.cabal cases (though I think in the case of cabal it can be inferred from the file name). - We should fall back to the directory name, as
vim.json.decodedoesn't work with yaml, and manual parsing is brittle. - Ideally, both Stack and Cabal should provide a
metadatacommand, similar to Cargo's, that would output project metadata as JSON.
I'll look into a hotfix after work later today.
Thanks for taking a look! I am not personally blocked[1] but thought I would report in case other people hit the same issue/for documentation. Thanks for developing this plugin.
[1] Especially since I found symlinks work around the issue (a symlink pointing to a directory with the right package name)