More wiring of lsp manager calls and responses

This commit is contained in:
2024-09-14 16:39:21 -05:00
parent e0664123da
commit bc52f62982
7 changed files with 125 additions and 84 deletions

View File

@@ -28,7 +28,7 @@ content_part = {
"params": {
"textDocument": {
"uri": "file:///",
"languageId": "python3",
"languageId": "python",
"version": 1,
"text": ""
},
@@ -45,21 +45,72 @@ didopen_notification = {
"params": {
"textDocument": {
"uri": "file://<path>",
"languageId": "python3",
"languageId": "python",
"version": 1,
"text": ""
}
}
}
didchange_notification = {
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file://<path>",
"languageId": "python",
"version": 1,
"text": ""
},
"contentChanges": [
{
"range": {
"start": {
"line": 1,
"character": 1,
},
"end": {
"line": 1,
"character": 1,
}
}
}
]
}
}
definition_query = {
# CompletionTriggerKind = 1 | 2 | 3;
# export const Invoked: 1 = 1;
# export const TriggerCharacter: 2 = 2;
# export const TriggerForIncompleteCompletions: 3 = 3;
completion_request = {
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file://",
"languageId": "python",
"version": 1,
"text": ""
},
"position": {
"line": 5,
"character": 12,
"offset": 0
},
"contet": {
"triggerKind": 3,
"triggerCharacter":
}
}
}
definition_request = {
"method": "textDocument/definition",
"params": {
"textDocument": {
"uri": "file:///home/abaddon/Coding/Projects/Active/Python_Projects/000_Usable/gtk/LSP-Manager/src/core/widgets/lsp_message_box.py",
"languageId": "python3",
"languageId": "python",
"version": 1,
"text": ""
},
@@ -71,7 +122,7 @@ definition_query = {
}
}
references_query = {
references_request = {
"method": "textDocument/references",
"params": {
"context": {
@@ -79,7 +130,7 @@ references_query = {
},
"textDocument": {
"uri": "file:///home/abaddon/Coding/Projects/Active/Python_Projects/000_Usable/gtk/LSP-Manager/src/core/widgets/lsp_message_box.py",
"languageId": "python3",
"languageId": "python",
"version": 1,
"text": ""
},
@@ -92,12 +143,12 @@ references_query = {
}
symbols_query = {
symbols_request = {
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
"uri": "file:///home/abaddon/Coding/Projects/Active/Python_Projects/000_Usable/gtk/LSP-Manager/src/core/widgets/lsp_message_box.py",
"languageId": "python3",
"languageId": "python",
"version": 1,
"text": ""
}

View File

@@ -1,4 +1,5 @@
# Python imports
import traceback
import os
import threading
import time
@@ -66,19 +67,21 @@ class LSPEndpointServer(Singleton):
start_time = time.perf_counter()
self._handle_ipc_message(conn, start_time)
except Exception as e:
logger.debug( repr(e) )
# logger.debug( repr(e) )
logger.debug( traceback.print_exc() )
listener.close()
def _handle_ipc_message(self, conn, start_time) -> None:
while True:
msg = conn.recv()
logger.debug(msg)
if "CLIENT|" in msg:
data = msg.split("CLIENT|")[1].strip()
if data:
data_str = base64.b64decode(data.encode("utf-8")).decode("utf-8")
logger.debug(data_str)
json_blob = json.loads(data_str)
event_system.emit(json_blob["method"], (json_blob,))
@@ -145,4 +148,4 @@ class LSPEndpointServer(Singleton):
logger.error("LSP Socket no longer valid.... Removing.")
os.unlink(self._ipc_address)
except Exception as e:
logger.error( repr(e) )
logger.error( repr(e) )

View File

@@ -109,13 +109,13 @@ class SettingsManager(StartCheckMixin, Singleton):
with open(self._LSP_CONFIG) as file:
self._lsp_config_data = json.load(file)
except Exception as e:
print( f"Settings Manager: {self._LSP_CONFIG}\n\t\t{repr(e)}" )
print( f"Settings Manager: {self._LSP_CONFIG}\n\t\t{repr(e)}" )
try:
with open(self._LSP_INIT_CONFIG) as file:
self._lsp_init_data = json.load(file)
except Exception as e:
print( f"Settings Manager: {self._LSP_INIT_CONFIG}\n\t\t{repr(e)}" )
print( f"Settings Manager: {self._LSP_INIT_CONFIG}\n\t\t{repr(e)}" )
self.settings: Settings = None
@@ -162,7 +162,7 @@ class SettingsManager(StartCheckMixin, Singleton):
def get_ui_widgets_path(self) -> str: return self._UI_WIDEGTS_PATH
def get_context_menu_data(self) -> str: return self._context_menu_data
def get_lsp_config_data(self) -> str: return self._lsp_config_data
def get_lsp_init_data(self) -> {}: return self._lsp_init_data
def get_lsp_init_data(self) -> dict: return self._lsp_init_data
def get_app_pid(self) -> int: return self.pid
def get_context_path(self) -> str: return self._CONTEXT_PATH
@@ -172,7 +172,7 @@ class SettingsManager(StartCheckMixin, Singleton):
def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH
def get_window_icon(self) -> str: return self._WINDOW_ICON
def get_home_path(self) -> str: return self._USER_HOME
def get_starting_files(self) -> []: return self._starting_files
def get_starting_files(self) -> list: return self._starting_files
def is_trace_debug(self) -> str: return self._trace_debug
def is_debug(self) -> str: return self._debug
@@ -197,7 +197,7 @@ class SettingsManager(StartCheckMixin, Singleton):
def set_debug(self, debug):
self._debug = debug
def set_is_starting_with_file(self, is_passed_in_file: False):
def set_is_starting_with_file(self, is_passed_in_file: bool = False):
self._passed_in_file = is_passed_in_file
def load_settings(self):
@@ -212,4 +212,4 @@ class SettingsManager(StartCheckMixin, Singleton):
def save_settings(self):
with open(self._CONFIG_FILE, 'w') as outfile:
json.dump(self.settings.as_dict(), outfile, separators=(',', ':'), indent=4)
json.dump(self.settings.as_dict(), outfile, separators=(',', ':'), indent=4)

View File

@@ -61,4 +61,4 @@ class StartCheckMixin:
def _write_pid(self, pid):
with open(self._PID_FILE, "w") as _pid:
_pid.write(f"{pid}")
_pid.write(f"{pid}")