Skip to content

Commit b696f4f

Browse files
Fix issue #1140, register LSP server capability dynamically.
1 parent 402e65f commit b696f4f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

core/lspserver.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,15 @@ def handle_work_done_progress_message(self, message):
870870
def handle_register_capability_message(self, message):
871871
if "method" in message and message["method"] in ["client/registerCapability"]:
872872
try:
873-
if message["params"]["registrations"][0]["id"] == "workspace/didChangeWatchedFiles":
874-
workspace_watch_files = self.parse_workspace_watch_files(message["params"])
875-
self.monitor_workspace_files(workspace_watch_files)
876-
log_time("Add workspace watch files: {}".format(workspace_watch_files))
873+
for registration in message["params"]["registrations"]:
874+
if registration["id"] == "workspace/didChangeWatchedFiles":
875+
workspace_watch_files = self.parse_workspace_watch_files(message["params"])
876+
self.monitor_workspace_files(workspace_watch_files)
877+
log_time("Add workspace watch files: {}".format(workspace_watch_files))
878+
elif registration["id"] == "textDocument/formatting":
879+
self.code_format_provider = True
880+
elif registration["id"] == "textDocument/rangeFormatting":
881+
self.range_format_provider = True
877882
except:
878883
log_time(traceback.format_exc())
879884

0 commit comments

Comments
 (0)