haskell / haskell/haskell-language-server

Migrate all plugins and ghcide to use structured diagnostics

Open
#4,605 7 comments 1 reaction 0 assignees View on GitHub
Hackathon type: enhancement
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
3d 21h
Merged PRs (30d)
13

Description

HLS uses in many locations regexes to extract information out of GHC diagnostics to then offer code actions based on them.
This has served us well for many years, but it is time for an improvement!
GHC has structured diagnostics since GHC 9.4 (at least), but HLS isn't really using them, even though we keep them around since #4433.

This issue tracks the effort to update the full HLS codebase to use structured diagnostics instead of handwritten regex matchers.

* [x] ghcide (huge amount of work)
* [x] hls-alternate-number-format-plugin
* [x] hls-change-type-signature-plugin (#4632 @sgillespie)
* [x] hls-class-plugin (#4472 @fendor)
* [x] hls-code-range-plugin
* [x] hls-eval-plugin
* [x] hls-explicit-fixity-plugin
* [x] hls-explicit-imports-plugin
* [x] hls-explicit-record-fields-plugin
* [x] hls-gadt-plugin
* [x] hls-hlint-plugin
* [x] hls-module-name-plugin
* [x] hls-overloaded-record-dot-plugin (@FuriousSheep)
* [x] hls-pragmas-plugin (#4620 @dyniec)
* [x] hls-qualify-imported-names-plugin
* [ ] hls-refactor-plugin (huge amount of work)
* [x] hls-rename-plugin
* [x] hls-retrie-plugin
* [x] hls-splice-plugin
* [x] hls-stan-plugin

Not all the listed plugins actually benefit from structured diagnostics, but we need to check which ones need to be updated. For example, I don't think `hls-stan-plugin` uses ghc in any way, so will likely not need updating.
I will update the list as time goes on.

The task for each of these plugins/packages would be to check whether the plugin needs updating, try to migrate it to use structured diagnostics or document what is *missing* to migrate them to structured diagnostics. This may require us to send issues to GHC upstream.

If you need inspiration for what this migration may look like, the PR #4472 migrates the `hls-class-plugin` to use structured diagnostics.

I am planning to present this issue at ZuriHac, if you want to work on migrating a plugin, please comment here and I will update the table.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the unchecked hls-refactor-plugin entry and the structured-diagnostics migration in PR #4472. Check whether the plugin uses GHC diagnostics, then either migrate it to structured diagnostics or document what is missing and any required GHC upstream work.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.