generated from itdominator/Python-With-Gtk-Template
fixed goto/definition with full text transfer; cleanup
This commit is contained in:
parent
4d65197845
commit
46d358aab7
|
@ -1,4 +1,5 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
|
import traceback
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
@ -12,7 +13,9 @@ import gi
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from .lsp_message_structs import LSPResponseRequest, LSPResponseNotification, get_message_obj
|
from .lsp_message_structs import LSPResponseRequest
|
||||||
|
from .lsp_message_structs import LSPResponseNotification
|
||||||
|
from .lsp_message_structs import get_message_obj
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,13 +129,17 @@ class ClientIPC:
|
||||||
def send_manager_ipc_message(self, message: str) -> None:
|
def send_manager_ipc_message(self, message: str) -> None:
|
||||||
try:
|
try:
|
||||||
if self._conn_type == "socket":
|
if self._conn_type == "socket":
|
||||||
|
if not os.path.exists(self._manager_ipc_address):
|
||||||
|
logger.error(f"Socket: {self._manager_ipc_address} doesn't exist. NOT sending message...")
|
||||||
|
return
|
||||||
|
|
||||||
conn = Client(address=self._manager_ipc_address, family="AF_UNIX", authkey=self._manager_ipc_authkey)
|
conn = Client(address=self._manager_ipc_address, family="AF_UNIX", authkey=self._manager_ipc_authkey)
|
||||||
elif "unsecured" not in self._conn_type:
|
elif "unsecured" not in self._conn_type:
|
||||||
conn = Client((self._ipc_address, self._ipc_port), authkey=self._ipc_authkey)
|
conn = Client((self._ipc_address, self._ipc_port), authkey=self._ipc_authkey)
|
||||||
else:
|
else:
|
||||||
conn = Client((self._ipc_address, self._ipc_port))
|
conn = Client((self._ipc_address, self._ipc_port))
|
||||||
|
|
||||||
conn.send( f"CLIENT|{ base64.b64encode(message.encode("utf-8")).decode("utf-8") }" )
|
conn.send( f"CLIENT|{ base64.b64encode(message.encode('utf-8')).decode('utf-8') }" )
|
||||||
conn.close()
|
conn.close()
|
||||||
except ConnectionRefusedError as e:
|
except ConnectionRefusedError as e:
|
||||||
logger.error("Connection refused...")
|
logger.error("Connection refused...")
|
||||||
|
|
|
@ -178,14 +178,10 @@ class Plugin(PluginBase):
|
||||||
iter = buffer.get_iter_at_mark( buffer.get_insert() )
|
iter = buffer.get_iter_at_mark( buffer.get_insert() )
|
||||||
line = iter.get_line()
|
line = iter.get_line()
|
||||||
column = iter.get_line_offset()
|
column = iter.get_line_offset()
|
||||||
start = iter.copy()
|
|
||||||
end = iter.copy()
|
|
||||||
|
|
||||||
start.backward_line()
|
start, end = buffer.get_bounds()
|
||||||
start.forward_line()
|
|
||||||
end.forward_to_line_end()
|
|
||||||
|
|
||||||
text = buffer.get_text(start, end, include_hidden_chars = False)
|
text = buffer.get_text(start, end, include_hidden_chars = True)
|
||||||
data = {
|
data = {
|
||||||
"method": "textDocument/didChange",
|
"method": "textDocument/didChange",
|
||||||
"language_id": language_id,
|
"language_id": language_id,
|
||||||
|
@ -199,6 +195,35 @@ class Plugin(PluginBase):
|
||||||
|
|
||||||
self.send_message(data)
|
self.send_message(data)
|
||||||
|
|
||||||
|
|
||||||
|
# def _lsp_did_change(self, language_id: str, uri: str, buffer):
|
||||||
|
# if not self.lsp_client_proc: return
|
||||||
|
|
||||||
|
# iter = buffer.get_iter_at_mark( buffer.get_insert() )
|
||||||
|
# line = iter.get_line()
|
||||||
|
# column = iter.get_line_offset()
|
||||||
|
# start = iter.copy()
|
||||||
|
# end = iter.copy()
|
||||||
|
|
||||||
|
# start.backward_line()
|
||||||
|
# start.forward_line()
|
||||||
|
# end.forward_line()
|
||||||
|
|
||||||
|
# text = buffer.get_text(start, end, include_hidden_chars = True)
|
||||||
|
# data = {
|
||||||
|
# "method": "textDocument/didChange",
|
||||||
|
# "language_id": language_id,
|
||||||
|
# "uri": uri,
|
||||||
|
# "version": buffer.version_id,
|
||||||
|
# "text": text,
|
||||||
|
# "line": line,
|
||||||
|
# "column": column,
|
||||||
|
# "char": ""
|
||||||
|
# }
|
||||||
|
|
||||||
|
# self.send_message(data)
|
||||||
|
|
||||||
|
|
||||||
def _lsp_goto(self, language_id: str, uri: str, line: int, column: int):
|
def _lsp_goto(self, language_id: str, uri: str, line: int, column: int):
|
||||||
if not self.lsp_client_proc: return
|
if not self.lsp_client_proc: return
|
||||||
|
|
||||||
|
@ -225,12 +250,9 @@ class Plugin(PluginBase):
|
||||||
buffer = source_view.get_buffer()
|
buffer = source_view.get_buffer()
|
||||||
iter = buffer.get_iter_at_mark( buffer.get_insert() )
|
iter = buffer.get_iter_at_mark( buffer.get_insert() )
|
||||||
line = iter.get_line()
|
line = iter.get_line()
|
||||||
|
|
||||||
char = iter.get_char()
|
|
||||||
if iter.backward_char():
|
|
||||||
char = iter.get_char()
|
|
||||||
|
|
||||||
column = iter.get_line_offset()
|
column = iter.get_line_offset()
|
||||||
|
char = iter.get_char()
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"method": "textDocument/completion",
|
"method": "textDocument/completion",
|
||||||
"language_id": source_view.get_filetype(),
|
"language_id": source_view.get_filetype(),
|
||||||
|
|
Loading…
Reference in New Issue