Skip to content

Commit a181629

Browse files
authored
Merge pull request #246 from taminomara/fix-todo
Fix debug port setting
2 parents 768da5d + 8e72c02 commit a181629

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,11 @@
913913
"default": "off",
914914
"scope": "window",
915915
"markdownDescription": "%config.lua.trace.server.description%"
916+
},
917+
"emmylua.ls.debugPort": {
918+
"type": ["integer", "null"],
919+
"default": null,
920+
"markdownDescription": "Look for language server on this port instead of starting it from an executable"
916921
}
917922
}
918923
}

src/extension.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as net from "net";
66
import * as process from "process";
77
import * as Annotator from "./annotator";
88

9-
import { LanguageClient, LanguageClientOptions, ServerOptions, StreamInfo } from "vscode-languageclient/node";
9+
import { integer, LanguageClient, LanguageClientOptions, ServerOptions, StreamInfo } from "vscode-languageclient/node";
1010
import { LuaLanguageConfiguration } from './languageConfiguration';
1111
import { EmmyNewDebuggerProvider } from './debugger/new_debugger/EmmyNewDebuggerProvider';
1212
import { EmmyAttachDebuggerProvider } from './debugger/attach/EmmyAttachDebuggerProvider';
@@ -114,10 +114,15 @@ async function doStartServer() {
114114
};
115115

116116
let serverOptions: ServerOptions;
117-
if (ctx.debugMode && false) { // TODO: Do NOT commit
117+
const config = vscode.workspace.getConfiguration(
118+
undefined,
119+
vscode.workspace.workspaceFolders?.[0]
120+
);
121+
const debugPort = config.get<integer | null>("emmylua.ls.debugPort");
122+
if (debugPort) {
118123
// The server is a started as a separate app and listens on port 5007
119124
const connectionInfo = {
120-
port: 5007
125+
port: debugPort
121126
};
122127
serverOptions = () => {
123128
// Connect to language server via socket
@@ -132,10 +137,6 @@ async function doStartServer() {
132137
return Promise.resolve(result);
133138
};
134139
} else {
135-
const config = vscode.workspace.getConfiguration(
136-
undefined,
137-
vscode.workspace.workspaceFolders?.[0]
138-
);
139140
let configExecutablePath = get<string>(config, "emmylua.ls.executablePath")?.trim();
140141
if (!configExecutablePath || configExecutablePath.length == 0) {
141142
let platform = os.platform();

0 commit comments

Comments
 (0)