adjsut completion Items

This commit is contained in:
Christoph Brandau
2025-07-31 09:38:02 +02:00
parent ed045aa459
commit d90f9b5425
2 changed files with 8 additions and 5 deletions
+5 -4
View File
@@ -213,6 +213,10 @@ def did_change(params: lsp.DidChangeTextDocumentParams) -> None:
"""LSP handler for textDocument/didChange request"""
document = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
LSP_SERVER.compute_diagnostics(document)
ci = _Completion()
tree = LSP_SERVER.parser.parse(document.source)
tree.accept(ci, recurse=True)
LSP_SERVER._custom_functions = ci.custom_functions
@LSP_SERVER.feature(
@@ -243,15 +247,12 @@ def document_diagnostic(params: lsp.DocumentDiagnosticParams):
@LSP_SERVER.feature(lsp.TEXT_DOCUMENT_COMPLETION)
def on_completion(params: lsp.CompletionParams) -> list[lsp.CompletionItem]:
document = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
ci = _Completion()
tree = LSP_SERVER.parser.parse(document.source)
tree.accept(ci, recurse=True)
items = (
standard_items.tcl_keyword_list
+ standard_items.nx_procs
+ standard_items.nx_variables
+ ci.custom_functions
+ LSP_SERVER._custom_functions
)
return lsp.CompletionList(is_incomplete=False, items=items)
+3 -1
View File
@@ -29,7 +29,9 @@ class _Completion(Visitor):
if routine.contents == "proc" and command.args:
first_arg = command.args[0]
if hasattr(first_arg, "value"):
if hasattr(first_arg, "value") and not any(
item.label == first_arg.value for item in self._custom_functions
):
self._custom_functions.append(
lsp.CompletionItem(
label=first_arg.value, kind=lsp.CompletionItemKind.Function