tcl_language_support #19
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user