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._start_command = None
self._socket = None
self._lsp_pid = -1
self._message_id = 0
@ -64,6 +65,12 @@ class LSPController(LSPControllerWebsocket):
def unset_start_command(self):
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: {} = {}):
self._send_message( ClientNotification(method, params) )

View File

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

View File

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

View File

@ -14,7 +14,13 @@ from . import websocket
class WebsocketClient:
def __init__(self):
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):
self.ws.send(message)
@ -39,16 +45,14 @@ class WebsocketClient:
@daemon_threaded
def start_client(self):
if not self._socket:
raise Exception("Socket address isn't set so cannot start WebsocketClient listener...")
# websocket.enableTrace(True)
self.ws = websocket.WebSocketApp("ws://localhost:4114",
self.ws = websocket.WebSocketApp(self._socket,
on_open = self.on_open,
on_message = self.on_message,
on_error = self.on_error,
on_close = self.on_close)
# Set dispatcher to automatic reconnection, 5 second reconnect delay
# 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": {
"info": "",
"command": "",
"alt-command": "",
"socket": "ws://127.0.0.1:3030/?name=shell",
"java": {
"info": "https://download.eclipse.org/jdtls/",
"link": "https://download.eclipse.org/jdtls/milestones/?d",
"command": "lsp-ws-proxy -- jdtls",
"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": {}
},
"python": {
"info": "https://github.com/python-lsp/python-lsp-server",
"command": "pylsp --ws --port 4114",
"command": "lsp-ws-proxy -- pylsp",
"alt-command": "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": {
"pylsp": {
"plugins": {
@ -50,8 +54,8 @@
"python - pylsp": {
"hidden": true,
"info": "https://github.com/python-lsp/python-lsp-server",
"command": "lsp-ws-proxy --listen 3030 -- pylsp",
"alt-command": "pylsp",
"command": "pylsp",
"alt-command": "lsp-ws-proxy --listen 3030 -- pylsp",
"alt-command2": "pylsp --ws --port 3030",
"socket": "ws://127.0.0.1:3030/?name=pylsp",
"initialization-options": {
@ -79,8 +83,8 @@
"python - jedi-language-server": {
"hidden": true,
"info": "https://pypi.org/project/jedi-language-server/",
"command": "lsp-ws-proxy --listen 3030 -- jedi-language-server",
"alt-command": "jedi-language-server",
"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",
"initialization-options": {
"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": {
"info": "https://clangd.llvm.org/",
"command": "lsp-ws-proxy --listen 3030 -- clangd",
"command": "lsp-ws-proxy -- clangd",
"alt-command": "clangd",
"socket": "ws://127.0.0.1:3030/?name=clangd",
"initialization-options": {}
},
"java": {
"info": "https://download.eclipse.org/jdtls/",
"command": "lsp-ws-proxy --listen 3030 -- java-language-server",
"alt-command": "java-language-server",
"socket": "ws://127.0.0.1:3030/?name=java-language-server",
"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",
"sh": {
"info": "",
"command": "",
"alt-command": "",
"socket": "ws://127.0.0.1:3030/?name=shell",
"initialization-options": {}
},
"go": {
"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",
"socket": "ws://127.0.0.1:3030/?name=gopls",
"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": {}
}
}