From 5b5850729ce1574bf5da1285441447a3887761a3 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Wed, 1 Apr 2026 00:39:21 -0500 Subject: [PATCH] Updated to pass workspace as parameter for server args --- Docker/Dockerfile | 1 + src/index.js | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 55629ea..06de89b 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -26,6 +26,7 @@ ENV PATH="${JAVA_LS_PATH}/:${PATH}" ENV PATH="${JDTLS_PATH}/bin:${PATH}" ENV PATH="${MAVEN_PATH}/bin:${PATH}" ENV PATH="${JAVA_HOME}/bin:${PATH}" +ENV PATH="/opt:${PATH}" ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 diff --git a/src/index.js b/src/index.js index 22bea36..bbca33a 100644 --- a/src/index.js +++ b/src/index.js @@ -28,24 +28,29 @@ console.log("Started websocket server on port: ", _port); wss.on('connection', (ws, req) => { - const pathname = url.parse(req.url).pathname; - handleLanguageConnection(ws, pathname.substring(1)); + // ws://localhost:6005/gdscript?workspace=/yolo + const address = url.parse(req.url, true); + const pathname = address.pathname.substring(1); + const qdata = address.query; + const workspace = qdata.workspace; + + handleLanguageConnection(ws, pathname, workspace); }); -function handleLanguageConnection(ws, pathname) { +function handleLanguageConnection(ws, pathname, workspace) { const server = servers.find(server => server.endpointName === pathname); - setupLanguageServer(ws, server); + setupLanguageServer(ws, server, workspace); } -function setupLanguageServer(ws, server) { +function setupLanguageServer(ws, server, workspace) { if (!server) return; const { reader, writer - } = startLanguageServer(server); + } = startLanguageServer(server, workspace); server.writer = writer; @@ -76,9 +81,12 @@ function setupLanguageServer(ws, server) { }); } -function startLanguageServer(languageServer) { - let env = process.env; - const serverProcess = spawn(...languageServer.args, {env, shell: true}); +function startLanguageServer(languageServer, workspace) { + const env = process.env; + const args = languageServer.args.map(arg => + typeof arg === 'string' ? arg.replace('{workspace.path}', workspace || '') : arg + ).filter(arg => arg !== ''); + const serverProcess = spawn(...args, {env, shell: true}); serverProcess.stderr.on('data', data => { console.error(`${serverProcess.spawnfile} error: ${data}`);