diff --git a/src/core/widgets/base/notebook/editor_controller.py b/src/core/widgets/base/notebook/editor_controller.py index 8ada7a0..ccdab1c 100644 --- a/src/core/widgets/base/notebook/editor_controller.py +++ b/src/core/widgets/base/notebook/editor_controller.py @@ -3,6 +3,7 @@ # Lib imports # Application imports +from libs.dto.lsp_message_structs import LSPResponseTypes, LSPResponseRequest, LSPResponseNotification from .key_input_controller import KeyInputController from .editor_events import EditorEventsMixin @@ -30,4 +31,12 @@ class EditorControllerMixin(KeyInputController, EditorEventsMixin): if action == "set_buffer_language": self.set_buffer_language(source_view, query) if action == "set_buffer_style": - self.set_buffer_style(source_view, query) \ No newline at end of file + self.set_buffer_style(source_view, query) + + def _handle_lsp_message(self, message: dict or LSPResponseTypes): + if isinstance(message, dict): + ... + if isinstance(message, LSPResponseRequest): + ... + if isinstance(message, LSPResponseNotification): + ... diff --git a/src/core/widgets/base/notebook/editor_notebook.py b/src/core/widgets/base/notebook/editor_notebook.py index f7b696e..03f3927 100644 --- a/src/core/widgets/base/notebook/editor_notebook.py +++ b/src/core/widgets/base/notebook/editor_notebook.py @@ -58,6 +58,8 @@ class EditorNotebook(EditorControllerMixin, Gtk.Notebook): self.connect("key-release-event", self._key_release_event) def _subscribe_to_events(self): + event_system.subscribe("handle-lsp-message", self._handle_lsp_message) + event_system.subscribe("create_view", self._create_view) event_system.subscribe("set_buffer_style", self.action_controller) event_system.subscribe("set_buffer_language", self.action_controller) @@ -140,4 +142,4 @@ class EditorNotebook(EditorControllerMixin, Gtk.Notebook): self.action_controller("scale_up_text") def _keyboard_scale_down_text(self): - self.action_controller("scale_down_text") \ No newline at end of file + self.action_controller("scale_down_text") diff --git a/src/core/widgets/base/sourceview/source_view_events.py b/src/core/widgets/base/sourceview/source_view_events.py index 2b307e1..673db85 100644 --- a/src/core/widgets/base/sourceview/source_view_events.py +++ b/src/core/widgets/base/sourceview/source_view_events.py @@ -26,7 +26,7 @@ class SourceViewEvents(SourceViewDnDMixin, MarkEventsMixin, FileEventsMixin): if not self._loading_file: event_system.emit("buffer_changed", (buffer, )) - event_system.emit("textDocument/didChange", (file_type, buffer, )) + event_system.emit("textDocument/didChange", (file_type, self.get_current_file().get_uri(), buffer, )) event_system.emit("textDocument/completion", (self, )) self.update_cursor_position(buffer) diff --git a/src/libs/dto/__init__.py b/src/libs/dto/__init__.py new file mode 100644 index 0000000..397e85d --- /dev/null +++ b/src/libs/dto/__init__.py @@ -0,0 +1,3 @@ +""" + Dasta Class module +""" diff --git a/src/libs/dto/lsp_message_structs.py b/src/libs/dto/lsp_message_structs.py new file mode 100644 index 0000000..fc1a325 --- /dev/null +++ b/src/libs/dto/lsp_message_structs.py @@ -0,0 +1,41 @@ +# Python imports +from dataclasses import dataclass +import json + +# Lib imports + +# Application imports + + + +def get_message_obj(data: str): + return json.loads(data) + + +@dataclass +class LSPResponseRequest(object): + """ + Constructs a new LSP Response Request instance. + + :param id result: The id of the given message. + :param dict result: The arguments of the given method. + """ + jsonrpc: str + id: int + result: dict + +@dataclass +class LSPResponseNotification(object): + """ + Constructs a new LSP Response Notification instance. + + :param str method: The type of lsp notification being made. + :params dict result: The arguments of the given method. + """ + jsonrpc: str + method: str + params: dict + + +class LSPResponseTypes(LSPResponseRequest, LSPResponseNotification): + ... \ No newline at end of file