diff --git a/core/lspserver.py b/core/lspserver.py index b7ca4646fa..640acde447 100755 --- a/core/lspserver.py +++ b/core/lspserver.py @@ -112,10 +112,15 @@ def send_response(self, request_id, result, **kwargs): ), **kwargs) def send_message(self, message: dict): - json_content = json.dumps(message) + # message_type is not valid key of JSONRPC, we need remove message_type before send LSP server. + message_type = message.get("message_type") + message.pop("message_type") + # Parse json content. + json_content = json.dumps(message) message_str = "Content-Length: {}\r\n\r\n{}".format(len(json_content), json_content) + # Send to LSP server. self.process.stdin.write(message_str.encode("utf-8")) # type: ignore self.process.stdin.flush() # type: ignore @@ -123,8 +128,6 @@ def send_message(self, message: dict): # So we need INLAY_HINT_REQUEST_ID_DICT to contain documentation path to send retry request. record_inlay_hint_request(message) - message_type = message.get("message_type") - if message_type == "request" and \ not message.get('method', 'response') == 'textDocument/documentSymbol': log_time("Send {} request ({}) to '{}' for project {}".format( diff --git a/langserver/terraform-ls.json b/langserver/terraform-ls.json index 56c27684ac..9f77566f21 100644 --- a/langserver/terraform-ls.json +++ b/langserver/terraform-ls.json @@ -2,7 +2,8 @@ "name": "terraform-ls", "languageId": "terraform", "command": [ - "terraform-ls" + "terraform-ls", + "serve" ], "settings": {} }