Implement completionItem/resolve
Implement completionItem/resolve to lazily resolve types and documentation for completion items.
This results in very big memory usage improvments while also improving the responsiveness of completions.
Usually when GHC typechecks code, it reads in and deserializes interfaces lazily, so if the code imports
a bunch of modules, the interfaces will only be read in and deserialized if a particular name is actually
required for typechecking.
However, when we greedily generate completion lists, the act of querying for types and documentation results in sucking in and deserializing interface sections for every single name in scope. This is very bad for memory usage as it negates virtually all the benefits of lazy deserialization.
Instead, we can compute types and documentation on demand for individual completion items using the completionItem/resolve
LSP functionality.
A downside to this is that we can no longer generate snippets for functions
arguments with placeholders mentioning the types because we no longer have this
information available when we generate the original completion, and it is not
supported by LSP to resolve the actual completion snippet using completionItem/resolve.
However, I don't personally consider this to be a very big deal because this feature was unreliable (eg for things from the export map which weren't in scope) and I found it to be quite annoying when it did work.
Wow, this is a big deal!
Also: tests?
Oh one last thing: we definitely want a cautionary comment on the main completion handler warning people not to accidentally pull in information from interface files in future!
https://github.com/haskell/haskell-language-server/pull/3080 gets the HIE file during completions, is that acceptable?
https://github.com/haskell/haskell-language-server/pull/3080 gets the HIE file during completions, is that acceptable?
I am pretty confident getting the HIE file is 👍
I merged the record dot completions PR, which has introduced some conflicts.
pre-commit check is also failing, I think you're missing formatting