Skip to content
Snippets Groups Projects
Commit d6d8c7d8 authored by 最萌小汐's avatar 最萌小汐
Browse files

add support for `Lua.misc.executablePath`

parent 2a76f7d2
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,24 @@ class LuaClient { ...@@ -67,6 +67,24 @@ class LuaClient {
}; };
let config = vscode_1.workspace.getConfiguration(undefined, (_a = vscode.workspace.workspaceFolders) === null || _a === void 0 ? void 0 : _a[0]); let config = vscode_1.workspace.getConfiguration(undefined, (_a = vscode.workspace.workspaceFolders) === null || _a === void 0 ? void 0 : _a[0]);
let commandParam = config.get("Lua.misc.parameters"); let commandParam = config.get("Lua.misc.parameters");
let command = yield this.getCommand(config);
let serverOptions = {
command: command,
args: commandParam,
};
this.client = new node_1.LanguageClient('Lua', 'Lua', serverOptions, clientOptions);
//client.registerProposedFeatures();
yield this.client.start();
this.onCommand();
this.statusBar();
});
}
getCommand(config) {
return __awaiter(this, void 0, void 0, function* () {
let executablePath = config.get("Lua.misc.executablePath");
if (executablePath && executablePath != "") {
return executablePath;
}
let command; let command;
let platform = os.platform(); let platform = os.platform();
let binDir; let binDir;
...@@ -86,15 +104,7 @@ class LuaClient { ...@@ -86,15 +104,7 @@ class LuaClient {
yield fs.promises.chmod(command, '777'); yield fs.promises.chmod(command, '777');
break; break;
} }
let serverOptions = { return command;
command: command,
args: commandParam,
};
this.client = new node_1.LanguageClient('Lua', 'Lua', serverOptions, clientOptions);
//client.registerProposedFeatures();
yield this.client.start();
this.onCommand();
this.statusBar();
}); });
} }
stop() { stop() {
......
...@@ -72,6 +72,31 @@ class LuaClient { ...@@ -72,6 +72,31 @@ class LuaClient {
let config = Workspace.getConfiguration(undefined, vscode.workspace.workspaceFolders?.[0]); let config = Workspace.getConfiguration(undefined, vscode.workspace.workspaceFolders?.[0]);
let commandParam: string[] = config.get("Lua.misc.parameters"); let commandParam: string[] = config.get("Lua.misc.parameters");
let command: string = await this.getCommand(config);
let serverOptions: ServerOptions = {
command: command,
args: commandParam,
};
this.client = new LanguageClient(
'Lua',
'Lua',
serverOptions,
clientOptions
);
//client.registerProposedFeatures();
await this.client.start();
this.onCommand();
this.statusBar();
}
private async getCommand(config: vscode.WorkspaceConfiguration) {
let executablePath: string = config.get("Lua.misc.executablePath");
if (executablePath && executablePath != "") {
return executablePath;
}
let command: string; let command: string;
let platform: string = os.platform(); let platform: string = os.platform();
let binDir: string; let binDir: string;
...@@ -96,7 +121,7 @@ class LuaClient { ...@@ -96,7 +121,7 @@ class LuaClient {
'lua-language-server' 'lua-language-server'
) )
); );
await fs.promises.chmod(command, '777') await fs.promises.chmod(command, '777');
break; break;
case "darwin": case "darwin":
command = this.context.asAbsolutePath( command = this.context.asAbsolutePath(
...@@ -106,26 +131,10 @@ class LuaClient { ...@@ -106,26 +131,10 @@ class LuaClient {
'lua-language-server' 'lua-language-server'
) )
); );
await fs.promises.chmod(command, '777') await fs.promises.chmod(command, '777');
break; break;
} }
return command;
let serverOptions: ServerOptions = {
command: command,
args: commandParam,
};
this.client = new LanguageClient(
'Lua',
'Lua',
serverOptions,
clientOptions
);
//client.registerProposedFeatures();
await this.client.start();
this.onCommand();
this.statusBar();
} }
async stop() { async stop() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment