From b696f4f1e8bb7fc54d3ac44eb1ca6c0788d44701 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 1 Jan 2025 19:13:46 +0800 Subject: [PATCH] Fix issue #1140, register LSP server capability dynamically. --- core/lspserver.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/lspserver.py b/core/lspserver.py index 43ead4f1bb..88ad8b125a 100755 --- a/core/lspserver.py +++ b/core/lspserver.py @@ -870,10 +870,15 @@ def handle_work_done_progress_message(self, message): def handle_register_capability_message(self, message): if "method" in message and message["method"] in ["client/registerCapability"]: try: - if message["params"]["registrations"][0]["id"] == "workspace/didChangeWatchedFiles": - workspace_watch_files = self.parse_workspace_watch_files(message["params"]) - self.monitor_workspace_files(workspace_watch_files) - log_time("Add workspace watch files: {}".format(workspace_watch_files)) + for registration in message["params"]["registrations"]: + if registration["id"] == "workspace/didChangeWatchedFiles": + workspace_watch_files = self.parse_workspace_watch_files(message["params"]) + self.monitor_workspace_files(workspace_watch_files) + log_time("Add workspace watch files: {}".format(workspace_watch_files)) + elif registration["id"] == "textDocument/formatting": + self.code_format_provider = True + elif registration["id"] == "textDocument/rangeFormatting": + self.range_format_provider = True except: log_time(traceback.format_exc())