Closed olafurpg closed 5 years ago
Just adding that also the TypeScript LSP does this (and it even handles binpacking :O )
I actually worked on this feature about a month ago but never got around to complete the PR
The missing piece was that I don't know yet where to insert the import. I was thinking that it might be nice for starters to insert the import in the leading line above the completion. That would allow you to manually place the import where you like. Any thoughts?
That's cool!
I would just put it on top of the file, after the last import, similarly to what addGlobalImport
does.
A future improvement could be adding it to an existing import group if any.
Metals doesn't support completions anymore. Completions may get added back in the future but for now I think it's best to close completion-related tickets.
Currently, completions only suggest symbols that are available in your active scope. It would be nice if the completions also included symbols that are accessible with an import. LSP CompletionItem has an optional
textEdit
field to support inserting the import on completionThe Java LSP seems to be taking advantage of this.
Complete, and import is inserted