Skip to content

Commit 2bd43e9

Browse files
authored
Merge pull request #227 from georgiy-belyanin/global-config-opt
add option for specifying global configuration
2 parents 0d1f17f + ce9ff9e commit 2bd43e9

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@
295295
"default": "",
296296
"description": "%config.misc.executablePath%"
297297
},
298+
"emmylua.misc.globalConfigPath": {
299+
"type": "string",
300+
"default": "",
301+
"description": "%config.misc.globalConfigPath%"
302+
},
298303
"lua.trace.server": {
299304
"type": "string",
300305
"enum": [

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"debug.launch.blockOnExit": "block process when exit",
1616
"debug.launch.newWindow": "create new windows",
1717
"config.autoInsertTripleDash.description": "Automatically insert \"---\" when line breaking after a comment",
18-
"config.misc.executablePath": "Specify the executable file path in VSCode"
18+
"config.misc.executablePath": "Specify the executable file path in VSCode",
19+
"config.misc.globalConfigPath": "Specify a path to the global configuration file"
1920
}

package.nls.zh-cn.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"debug.launch.blockOnExit": "进程结束时是否阻塞进程保持窗口开启",
1616
"debug.launch.newWindow": "emmylua会创建一个新窗口展示这个进程",
1717
"config.autoInsertTripleDash.description": "在注解后换行时自动插入 \"---\"",
18-
"config.misc.executablePath": "VSCode中指定可执行文件路径"
18+
"config.misc.executablePath": "VSCode中指定可执行文件路径",
19+
"config.misc.globalConfigPath": "指定全局配置文件的路径"
1920
}

src/extension.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,22 @@ async function doStartServer() {
148148

149149
serverOptions = {
150150
command: configExecutablePath,
151-
args: []
151+
args: [],
152+
options: { env: {} }
152153
};
153154

154155
let parameters = config.get<string[]>("emmylua.ls.startParameters");
155156
if (parameters && parameters.length > 0) {
156157
serverOptions.args = parameters;
157158
}
159+
160+
let globalConfigPath = config.get<string>("emmylua.misc.globalConfigPath")?.trim();
161+
if (globalConfigPath && globalConfigPath.length > 0) {
162+
if (!serverOptions.options || !serverOptions.options.env) {
163+
serverOptions.options = { env: {} }
164+
}
165+
serverOptions.options.env['EMMYLUALS_CONFIG'] = globalConfigPath;
166+
}
158167
}
159168

160169
ctx.client = new LanguageClient(ctx.LANGUAGE_ID, "EmmyLua plugin for vscode.", serverOptions, clientOptions);

0 commit comments

Comments
 (0)