completions: Complete available namespaces

Add completions for namespaces in the typelib path that can be imported.
Accepting the completion automatically adds an import statement.
This commit is contained in:
James Westman 2025-01-04 16:05:27 -06:00
parent 461fe25316
commit 21f138fa83
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
3 changed files with 37 additions and 7 deletions

View file

@ -87,6 +87,7 @@ class Completion:
text: T.Optional[str] = None
snippet: T.Optional[str] = None
detail: T.Optional[str] = None
additional_text_edits: T.Optional[T.List["TextEdit"]] = None
def to_json(self, snippets: bool):
insert_text = self.text or self.label
@ -114,6 +115,11 @@ class Completion:
"insertText": insert_text,
"insertTextFormat": insert_text_format,
"detail": self.detail if self.detail else None,
"additionalTextEdits": (
[edit.to_json() for edit in self.additional_text_edits]
if self.additional_text_edits
else None
),
}
return {k: v for k, v in result.items() if v is not None}