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 368 forks source link

Show versions of installed packages #4430

Open lucalabs-de opened 1 month ago

lucalabs-de commented 1 month ago

Implements #4416. Shows installed versions of cabal dependencies as inlay hints, or alternatively as code lenses when inlay hints are not supported.

2024-10-14-152038_1271x1059_scrot

Code Lenses are currently always displayed at the beginning of the line, I'm not sure if this is an error on my part or a VSCode thing. Depending on how the cabal file is formatted, this can look unpleasant:

2024-10-14-152248_867x341_scrot

I don't yet show the version information in the hover overlay as mentioned in the issue, since I was not sure how it should interplay with #4417. However, it should be a quick change to show it there as well.

fendor commented 1 month ago

Discussing the feature with @wz1000, HLS knows the exact package versions as it intercepts the cabal build requests containing the ghc-options -package-id base-4... -package-id aeson-2.2....

That means, given the HscEnv a particular .cabal version belongs to, we should be able to consult the UnitState and UnitInfoMap in particular to find the exact version dependencies without resorting to reading plan.json.

If you are interested in implementing this feature based on the ghc-options, I can try to write it down how I think it should work, or we can pair a little bit some time in the future?

lucalabs-de commented 1 month ago

That certainly seems like a more sensible approach. I'm definitely interested in implementing it. You can explain it here or we can pair, whatever works best for you.