generated from itdominator/Python-With-Gtk-Template
Initial wiring of lsp manager calls and responses
This commit is contained in:
parent
9836285f86
commit
07a0316703
|
@ -3,6 +3,7 @@
|
||||||
# Lib imports
|
# Lib imports
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
|
from libs.dto.lsp_message_structs import LSPResponseTypes, LSPResponseRequest, LSPResponseNotification
|
||||||
from .key_input_controller import KeyInputController
|
from .key_input_controller import KeyInputController
|
||||||
from .editor_events import EditorEventsMixin
|
from .editor_events import EditorEventsMixin
|
||||||
|
|
||||||
|
@ -31,3 +32,11 @@ class EditorControllerMixin(KeyInputController, EditorEventsMixin):
|
||||||
self.set_buffer_language(source_view, query)
|
self.set_buffer_language(source_view, query)
|
||||||
if action == "set_buffer_style":
|
if action == "set_buffer_style":
|
||||||
self.set_buffer_style(source_view, query)
|
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):
|
||||||
|
...
|
||||||
|
|
|
@ -58,6 +58,8 @@ class EditorNotebook(EditorControllerMixin, Gtk.Notebook):
|
||||||
self.connect("key-release-event", self._key_release_event)
|
self.connect("key-release-event", self._key_release_event)
|
||||||
|
|
||||||
def _subscribe_to_events(self):
|
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("create_view", self._create_view)
|
||||||
event_system.subscribe("set_buffer_style", self.action_controller)
|
event_system.subscribe("set_buffer_style", self.action_controller)
|
||||||
event_system.subscribe("set_buffer_language", self.action_controller)
|
event_system.subscribe("set_buffer_language", self.action_controller)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class SourceViewEvents(SourceViewDnDMixin, MarkEventsMixin, FileEventsMixin):
|
||||||
|
|
||||||
if not self._loading_file:
|
if not self._loading_file:
|
||||||
event_system.emit("buffer_changed", (buffer, ))
|
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, ))
|
event_system.emit("textDocument/completion", (self, ))
|
||||||
|
|
||||||
self.update_cursor_position(buffer)
|
self.update_cursor_position(buffer)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
"""
|
||||||
|
Dasta Class module
|
||||||
|
"""
|
|
@ -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):
|
||||||
|
...
|
Loading…
Reference in New Issue