haskell / haskell/haskell-language-server
Support `workspace/diagnostic` requests for project-wide diagnostics
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 13
Description
## Is your enhancement request related to a problem? Please describe.
To rephrase a sentence I've heard many years ago in a documentary about Scotland "When HLS works, neovim is the most beautiful place in the world" (for reference, the original sentence was "When it's sunny, Scotland is the most beautiful place in the world").
I've had various degrees of success using HLS over the years, spanning from big to large projects, open source or otherwise, and my weapon of choice has always been vim / neovim. To the best of my knowledge (correct me if I'm wrong), editors like vim/neovim/emacs/helix they all work by having their LSP client send requests to acquire the diagnostics for the current buffer, which works but is not as ergonomic as having something like a quickfix window being populated with _all_ the diagnostics for the whole project, so that we can stay within the editor without the usual ritual of "fix, run cabal build all, repeat".
Over the years a few plugins were developed to mitigate the issue; I know for example that `emacs` via `lsp-mode` loads all the files in a project inside the LSP "session" and for neovim plugins like [workspace-diagnostics](https://github.com/artemave/workspace-diagnostics.nvim) aim to do the same.
I _think_, but I'm not sure, that VSCode does something similar by indexing the files and loading them individually. Over the years I have tried a bit of everything, but as neovim feels like home to me and I was never able to switch, currently my workflow is a bit crippled given that the aforementioned plugin doesn't work particularly well, or rather it does but it's quite clunky and for large projects (where Template Haskell is heavily used) I'm getting bizzarre errors which I can't pinpoint if they come from HLS itself or from the way the neovim plugin loads them (and in which order, etc).
## Describe the solution you'd like
Recently neovim added support for [workspace diagnostics](https://github.com/neovim/neovim/pull/34262) via the [workspace/diagnostic](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_diagnostic) request that a client can make to an LSP server in order to grab all the diagnostics for the workspace, not just the open buffer.
Unfortunately we can't leverage that in neovim as HLS doesn't implement this command, and this ticket is about enquiring how feasible would be to implement it, and if this is a good idea at all in the context of HLS/Haskell.
Thanks a lot!
Alfredo
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the LSP 3.17 workspace/diagnostic specification and HLS's existing diagnostic handling; the issue names no source file or test. Determine whether HLS can provide project-wide diagnostics, then verify that Neovim can consume the request successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, neovim
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100