From f482c8db877954f462937c489aee93685a5cd6d2 Mon Sep 17 00:00:00 2001 From: Christoph Brandau Date: Thu, 17 Jul 2025 15:01:02 +0200 Subject: [PATCH] update tcl standard --- server/src/common/completion_list.json | 25 ++++++++++++++++++++----- server/src/common/load_data.py | 6 +++++- server/src/lsp_server.py | 4 ++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/server/src/common/completion_list.json b/server/src/common/completion_list.json index f69debf..78a9971 100644 --- a/server/src/common/completion_list.json +++ b/server/src/common/completion_list.json @@ -1,10 +1,25 @@ { "tcl": [ - "proc", - "puts", - "if", - "else", - "elseif" + { + "label": "proc", + "kind": "keyword" + }, + { + "label": "if", + "kind": "keyword" + }, + { + "label": "else", + "kind": "keyword" + }, + { + "label": "elseif", + "kind": "keyword" + }, + { + "label": "puts", + "kind": "function" + } ], "MOM_procs": [ { diff --git a/server/src/common/load_data.py b/server/src/common/load_data.py index 952f3fc..bd8643f 100644 --- a/server/src/common/load_data.py +++ b/server/src/common/load_data.py @@ -11,6 +11,7 @@ KIND_MAP = { "field": lsp.CompletionItemKind.Field, "module": lsp.CompletionItemKind.Module, "namespace": lsp.CompletionItemKind.Class, + "keyword": lsp.CompletionItemKind.Keyword, } @@ -41,7 +42,10 @@ class StandardCompletionItems: items = [] for i in data.get("tcl", []): items.append( - lsp.CompletionItem(label=i, kind=lsp.CompletionItemKind.Keyword) + lsp.CompletionItem( + label=i.get("label", ""), + kind=KIND_MAP.get(i.get("kind", ""), lsp.CompletionItemKind.Text), + ) ) return items diff --git a/server/src/lsp_server.py b/server/src/lsp_server.py index fd662a2..07cec2a 100644 --- a/server/src/lsp_server.py +++ b/server/src/lsp_server.py @@ -74,13 +74,13 @@ TOOL_ARGS = [] # default arguments always passed to your tool. @LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_OPEN) def did_open(params: lsp.DidOpenTextDocumentParams) -> None: """LSP handler for textDocument/didOpen request.""" - document = LSP_SERVER.workspace.get_document(params.text_document.uri) + document = LSP_SERVER.workspace.get_text_document(params.text_document.uri) @LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_SAVE) def did_save(params: lsp.DidSaveTextDocumentParams) -> None: """LSP handler for textDocument/didSave request.""" - document = LSP_SERVER.workspace.get_document(params.text_document.uri) + document = LSP_SERVER.workspace.get_text_document(params.text_document.uri) @LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_CLOSE)