wiring websocket info; updating lsp configs to use lsp-ws-proxy

This commit is contained in:
itdominator 2024-09-22 14:40:22 -05:00
parent de8fe47231
commit c9a1c84715
5 changed files with 67 additions and 48 deletions

View File

@ -32,6 +32,7 @@ class LSPController(LSPControllerWebsocket):
self._init_params = settings_manager.get_lsp_init_data() self._init_params = settings_manager.get_lsp_init_data()
self._start_command = None self._start_command = None
self._socket = None
self._lsp_pid = -1 self._lsp_pid = -1
self._message_id = 0 self._message_id = 0
@ -64,6 +65,12 @@ class LSPController(LSPControllerWebsocket):
def unset_start_command(self): def unset_start_command(self):
self._start_command = None self._start_command = None
def set_socket(self, socket: str):
self._socket = socket
def unset_socket(self):
self._socket = None
def send_notification(self, method: str, params: {} = {}): def send_notification(self, method: str, params: {} = {}):
self._send_message( ClientNotification(method, params) ) self._send_message( ClientNotification(method, params) )

View File

@ -49,6 +49,7 @@ class LSPControllerWebsocket(LSPControllerBase):
return return
self.ws_client = WebsocketClient() self.ws_client = WebsocketClient()
self.ws_client.set_socket(self._socket)
self.ws_client.set_callback(self._monitor_lsp_response) self.ws_client.set_callback(self._monitor_lsp_response)
self.ws_client.start_client() self.ws_client.start_client()
return self.lsp_process.pid return self.lsp_process.pid

View File

@ -86,13 +86,15 @@ class LSPMessageBox(Gtk.Box):
self.update_message_id_label() self.update_message_id_label()
def start_stop_lsp(self): def start_stop_lsp(self):
parent = self.get_parent() parent = self.get_parent()
_command: str = parent.command_entry.get_text() data: str = parent.command_entry.get_text()
# _command: str = parent.alt_command_entry.get_text() # data: str = parent.alt_command_entry.get_text()
# _command: str = parent.socket_entry.get_text() socket: str = parent.socket_entry.get_text()
command: [] = _command.split() if len( _command.split() ) > 0 else [ _command ] command: [] = data.split() if len( data.split() ) > 0 else [ data ]
self.lsp_controller.set_start_command(command) self.lsp_controller.set_start_command(command)
self.lsp_controller.set_socket(socket)
self.lsp_controller.start_stop_lsp() self.lsp_controller.start_stop_lsp()
self.lsp_controller.unset_start_command() self.lsp_controller.unset_start_command()
self.lsp_controller.unset_socket()
self.update_message_id_label() self.update_message_id_label()

View File

@ -13,8 +13,14 @@ from . import websocket
class WebsocketClient: class WebsocketClient:
def __init__(self): def __init__(self):
self.ws = None self.ws = None
self._socket = None
def set_socket(self, socket: str):
self._socket = socket
def unset_socket(self):
self._socket = None
def send(self, message: str): def send(self, message: str):
self.ws.send(message) self.ws.send(message)
@ -39,16 +45,14 @@ class WebsocketClient:
@daemon_threaded @daemon_threaded
def start_client(self): def start_client(self):
if not self._socket:
raise Exception("Socket address isn't set so cannot start WebsocketClient listener...")
# websocket.enableTrace(True) # websocket.enableTrace(True)
self.ws = websocket.WebSocketApp("ws://localhost:4114", self.ws = websocket.WebSocketApp(self._socket,
on_open = self.on_open, on_open = self.on_open,
on_message = self.on_message, on_message = self.on_message,
on_error = self.on_error, on_error = self.on_error,
on_close = self.on_close) on_close = self.on_close)
# Set dispatcher to automatic reconnection, 5 second reconnect delay self.ws.run_forever(reconnect = 0.5)
# self.ws.run_forever(dispatcher = rel, reconnect = 5)
# rel.signal(2, rel.abort) # Keyboard Interrupt
# rel.dispatch()
self.ws.run_forever(reconnect = 0.5)

View File

@ -1,17 +1,21 @@
{ {
"sh": { "java": {
"info": "", "info": "https://download.eclipse.org/jdtls/",
"command": "", "link": "https://download.eclipse.org/jdtls/milestones/?d",
"alt-command": "", "command": "lsp-ws-proxy -- jdtls",
"socket": "ws://127.0.0.1:3030/?name=shell", "alt-command": "java-language-server",
"alt-command2": "lsp-ws-proxy --listen 3030 -- java-language-server",
"socket": "ws://127.0.0.1:9999/?name=jdtls",
"alt-socket": "ws://127.0.0.1:3030/?name=java-language-server",
"initialization-options": {} "initialization-options": {}
}, },
"python": { "python": {
"info": "https://github.com/python-lsp/python-lsp-server", "info": "https://github.com/python-lsp/python-lsp-server",
"command": "pylsp --ws --port 4114", "command": "lsp-ws-proxy -- pylsp",
"alt-command": "pylsp", "alt-command": "pylsp",
"alt-command2": "lsp-ws-proxy --listen 4114 -- pylsp", "alt-command2": "lsp-ws-proxy --listen 4114 -- pylsp",
"socket": "ws://127.0.0.1:4114/?name=pylsp", "alt-command3": "pylsp --ws --port 4114",
"socket": "ws://127.0.0.1:9999/?name=pylsp",
"initialization-options": { "initialization-options": {
"pylsp": { "pylsp": {
"plugins": { "plugins": {
@ -50,8 +54,8 @@
"python - pylsp": { "python - pylsp": {
"hidden": true, "hidden": true,
"info": "https://github.com/python-lsp/python-lsp-server", "info": "https://github.com/python-lsp/python-lsp-server",
"command": "lsp-ws-proxy --listen 3030 -- pylsp", "command": "pylsp",
"alt-command": "pylsp", "alt-command": "lsp-ws-proxy --listen 3030 -- pylsp",
"alt-command2": "pylsp --ws --port 3030", "alt-command2": "pylsp --ws --port 3030",
"socket": "ws://127.0.0.1:3030/?name=pylsp", "socket": "ws://127.0.0.1:3030/?name=pylsp",
"initialization-options": { "initialization-options": {
@ -79,8 +83,8 @@
"python - jedi-language-server": { "python - jedi-language-server": {
"hidden": true, "hidden": true,
"info": "https://pypi.org/project/jedi-language-server/", "info": "https://pypi.org/project/jedi-language-server/",
"command": "lsp-ws-proxy --listen 3030 -- jedi-language-server", "command": "jedi-language-server",
"alt-command": "jedi-language-server", "alt-command": "lsp-ws-proxy --listen 3030 -- jedi-language-server",
"socket": "ws://127.0.0.1:3030/?name=jedi-language-server", "socket": "ws://127.0.0.1:3030/?name=jedi-language-server",
"initialization-options": { "initialization-options": {
"jediSettings": { "jediSettings": {
@ -106,39 +110,40 @@
} }
} }
}, },
"c": {
"info": "https://clangd.llvm.org/",
"command": "lsp-ws-proxy --listen 3030 -- clangd",
"alt-command": "clangd",
"socket": "ws://127.0.0.1:3030/?name=clangd",
"initialization-options": {}
},
"cpp": { "cpp": {
"info": "https://clangd.llvm.org/", "info": "https://clangd.llvm.org/",
"command": "lsp-ws-proxy --listen 3030 -- clangd", "command": "lsp-ws-proxy -- clangd",
"alt-command": "clangd", "alt-command": "clangd",
"socket": "ws://127.0.0.1:3030/?name=clangd", "socket": "ws://127.0.0.1:3030/?name=clangd",
"initialization-options": {} "initialization-options": {}
}, },
"java": { "sh": {
"info": "https://download.eclipse.org/jdtls/", "info": "",
"command": "lsp-ws-proxy --listen 3030 -- java-language-server", "command": "",
"alt-command": "java-language-server", "alt-command": "",
"socket": "ws://127.0.0.1:3030/?name=java-language-server", "socket": "ws://127.0.0.1:3030/?name=shell",
"initialization-options": {}
},
"lua": {
"info": "https://github.com/LuaLS/lua-language-server",
"command": "lsp-ws-proxy --listen 3030 -- lua-language-server",
"alt-command": "lua-language-server",
"socket": "ws://127.0.0.1:3030/?name=gopls",
"initialization-options": {} "initialization-options": {}
}, },
"go": { "go": {
"info": "https://pkg.go.dev/golang.org/x/tools/gopls#section-readme", "info": "https://pkg.go.dev/golang.org/x/tools/gopls#section-readme",
"command": "lsp-ws-proxy --listen 3030 -- gopls", "command": "lsp-ws-proxy -- gopls",
"alt-command": "gopls", "alt-command": "gopls",
"socket": "ws://127.0.0.1:3030/?name=gopls", "socket": "ws://127.0.0.1:3030/?name=gopls",
"initialization-options": {} "initialization-options": {}
},
"lua": {
"info": "https://github.com/LuaLS/lua-language-server",
"command": "lsp-ws-proxy -- lua-language-server",
"alt-command": "lua-language-server",
"socket": "ws://127.0.0.1:3030/?name=gopls",
"initialization-options": {}
},
"c": {
"hidden": true,
"info": "https://clangd.llvm.org/",
"command": "lsp-ws-proxy -- clangd",
"alt-command": "clangd",
"socket": "ws://127.0.0.1:3030/?name=clangd",
"initialization-options": {}
} }
} }