More wiring of lsp manager calls and responses 2

This commit is contained in:
itdominator 2024-09-15 00:21:16 -05:00
parent bc52f62982
commit 73e9babd2e
2 changed files with 46 additions and 15 deletions

View File

@ -5,7 +5,7 @@ import os
from gi.repository import GLib from gi.repository import GLib
# Application imports # Application imports
from libs.dto.lsp_messages import get_message_obj, didopen_notification, completion_request, didchange_notification from libs.dto.lsp_messages import get_message_obj, didopen_notification, didsave_notification, didclose_notification, completion_request, didchange_notification
@ -40,12 +40,21 @@ class LSPControllerEvents:
GLib.idle_add( self.send_notification, method, params ) GLib.idle_add( self.send_notification, method, params )
def _lsp_did_save(self, data: dict): def _lsp_did_save(self, data: dict):
# GLib.idle_add( self.send_notification, method, params ) method = data["method"]
... params = didsave_notification["params"]
params["textDocument"]["uri"] = data["uri"]
params["text"] = data["text"]
GLib.idle_add( self.send_notification, method, params )
def _lsp_did_close(self, data: dict): def _lsp_did_close(self, data: dict):
# GLib.idle_add( self.send_notification, method, params ) method = data["method"]
... params = didclose_notification["params"]
params["textDocument"]["uri"] = data["uri"]
GLib.idle_add( self.send_notification, method, params )
def _lsp_did_change(self, data: dict): def _lsp_did_change(self, data: dict):
method = data["method"] method = data["method"]
@ -55,13 +64,14 @@ class LSPControllerEvents:
params["textDocument"]["languageId"] = data["language_id"] params["textDocument"]["languageId"] = data["language_id"]
params["textDocument"]["version"] = data["version"] params["textDocument"]["version"] = data["version"]
contentChanges = params["contentChanges"][0] contentChanges = params["contentChanges"][0]
start = contentChanges["range"]["start"] start = contentChanges["range"]["start"]
end = contentChanges["range"]["end"] end = contentChanges["range"]["end"]
start["line"] = data["line"] contentChanges["text"] = data["text"]
start["character"] = 0 start["line"] = data["line"]
end["line"] = data["line"] start["character"] = 0
end["character"] = data["column"] end["line"] = data["line"]
end["character"] = data["column"]
GLib.idle_add( self.send_notification, method, params ) GLib.idle_add( self.send_notification, method, params )
@ -85,4 +95,4 @@ class LSPControllerEvents:
params["position"]["character"] = data["column"] params["position"]["character"] = data["column"]
GLib.idle_add( self.send_request, method, params ) GLib.idle_add( self.send_request, method, params )

View File

@ -40,6 +40,7 @@ content_part = {
} }
} }
didopen_notification = { didopen_notification = {
"method": "textDocument/didOpen", "method": "textDocument/didOpen",
"params": { "params": {
@ -52,6 +53,26 @@ didopen_notification = {
} }
} }
didsave_notification = {
"method": "textDocument/didSave",
"params": {
"textDocument": {
"uri": "file://<path>"
},
"text": ""
}
}
didclose_notification = {
"method": "textDocument/didClose",
"params": {
"textDocument": {
"uri": "file://<path>"
}
}
}
didchange_notification = { didchange_notification = {
"method": "textDocument/didChange", "method": "textDocument/didChange",
"params": { "params": {
@ -100,7 +121,7 @@ completion_request = {
}, },
"contet": { "contet": {
"triggerKind": 3, "triggerKind": 3,
"triggerCharacter": "triggerCharacter": ""
} }
} }
} }
@ -153,4 +174,4 @@ symbols_request = {
"text": "" "text": ""
} }
} }
} }