More wiring of lsp manager calls and responses

This commit is contained in:
itdominator 2024-09-15 00:24:26 -05:00
parent 07a0316703
commit ab74fdd811
5 changed files with 68 additions and 5 deletions

View File

@ -34,9 +34,64 @@ class EditorControllerMixin(KeyInputController, EditorEventsMixin):
self.set_buffer_style(source_view, query)
def _handle_lsp_message(self, message: dict or LSPResponseTypes):
if not self.is_editor_focused: return # TODO: Find way to converge this
page_num, container, source_view = self.get_active_view()
page_num = None
container = None
# logger.debug( repr(message) )
if isinstance(message, dict):
...
if isinstance(message, LSPResponseRequest):
...
keys = message.result.keys()
if "items" in keys:
self.handle_completion(message.result["items"])
if isinstance(message, LSPResponseNotification):
...
if message.method == "textDocument/publshDiagnostics":
logger.info( repr(message) )
...
source_view = None
# export const Text = 1;
# export const Method = 2;
# export const Function = 3;
# export const Constructor = 4;
# export const Field = 5;
# export const Variable = 6;
# export const Class = 7;
# export const Interface = 8;
# export const Module = 9;
# export const Property = 10;
# export const Unit = 11;
# export const Value = 12;
# export const Enum = 13;
# export const Keyword = 14;
# export const Snippet = 15;
# export const Color = 16;
# export const File = 17;
# export const Reference = 18;
# export const Folder = 19;
# export const EnumMember = 20;
# export const Constant = 21;
# export const Struct = 22;
# export const Event = 23;
# export const Operator = 24;
# export const TypeParameter = 25;
def handle_completion(self, items):
print()
print()
print()
print(len(items))
print()
print()
print()
for item in items:
if item["kind"] in [2, 3, 4, 5, 6, 7, 8, 10, 15]:
# print(item)
...

View File

@ -43,7 +43,7 @@ class EditorEventsMixin:
file_type = source_view.get_filetype()
if not file_type == "buffer":
uri = source_view.get_current_file().get_uri()
event_system.emit("textDocument/didClose", (file_type, uri,))
event_system.emit("textDocument/didClose", (uri,))
page_num = notebook.page_num(container)
source_view._cancel_current_file_watchers()

View File

@ -31,6 +31,7 @@ class FileEventsMixin:
def save_file(self):
self._skip_file_load = True
gfile = event_system.emit_and_await("save_file_dialog", (self._current_filename, self._current_file)) if not self._current_file else self._current_file
event_system.emit("textDocument/didSave", (self._current_file.get_uri(), self.get_text()))
if not gfile:
self._skip_file_load = False

View File

@ -37,6 +37,7 @@ class SourceView(SourceViewControllerMixin, GtkSource.View):
self._cut_buffer: str = ""
self._timer: threading.Timer = None
self._idle_id: int = None
self._version_id: int = 1
self._skip_file_load = False
self._ignore_internal_change = False
@ -87,6 +88,7 @@ class SourceView(SourceViewControllerMixin, GtkSource.View):
self.connect("key-release-event", self._key_release_event)
self.connect("button-press-event", self._button_press_event)
self.connect("scroll-event", self._scroll_event)
self.connect("show-completion", self._show_completion)
buffer = self.get_buffer()
buffer.connect('changed', self._is_modified)
@ -94,6 +96,8 @@ class SourceView(SourceViewControllerMixin, GtkSource.View):
buffer.connect('insert-text', self._insert_text)
buffer.connect('modified-changed', self._buffer_modified_changed)
def _show_completion(self):
event_system.emit("textDocument/completion", (self, ))
def _subscribe_to_events(self):
...
@ -115,4 +119,4 @@ class SourceView(SourceViewControllerMixin, GtkSource.View):
self._timer.start()
def _clear_cut_buffer(self):
self._cut_buffer = ""
self._cut_buffer = ""

View File

@ -25,9 +25,12 @@ class SourceViewEvents(SourceViewDnDMixin, MarkEventsMixin, FileEventsMixin):
file_type = self.get_filetype()
if not self._loading_file:
buffer.version_id = self._version_id
event_system.emit("buffer_changed", (buffer, ))
event_system.emit("textDocument/didChange", (file_type, self.get_current_file().get_uri(), buffer, ))
event_system.emit("textDocument/completion", (self, ))
self._version_id += 1
self.update_cursor_position(buffer)