Skip to content

Commit 49908b9

Browse files
committed
可以手动启动和关闭服务器
1 parent 169a121 commit 49908b9

File tree

10 files changed

+73
-2
lines changed

10 files changed

+73
-2
lines changed

client/src/languageserver.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ function registerCustomCommands(context: ExtensionContext) {
8282
command: 'lua.reloadFFIMeta',
8383
})
8484
}))
85+
86+
context.subscriptions.push(Commands.registerCommand('lua.startServer', async () => {
87+
deactivate();
88+
createClient(context);
89+
}));
90+
91+
context.subscriptions.push(Commands.registerCommand('lua.stopServer', async () => {
92+
deactivate();
93+
}));
8594
}
8695

8796
/** Creates a new {@link LuaClient} and starts it. */
@@ -144,6 +153,7 @@ class LuaClient extends Disposable {
144153
serverOptions,
145154
clientOptions
146155
);
156+
this.disposables.push(this.client);
147157

148158
//client.registerProposedFeatures();
149159
await this.client.start();
@@ -298,6 +308,7 @@ export function activate(context: ExtensionContext) {
298308
export async function deactivate() {
299309
if (defaultClient) {
300310
defaultClient.stop();
311+
defaultClient.dispose();
301312
defaultClient = null;
302313
}
303314
return undefined;

package.nls.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"command.addon_manager.open": "Lua: Open Addon Manager ...",
33
"command.exportDocument": "Lua: Export Document ...",
44
"command.reloadFFIMeta": "Lua: Reload luajit ffi meta",
5+
"command.startServer": "Lua: (debug) Start Language Server",
6+
"command.stopServer": "Lua: (debug) Stop Language Server",
57
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
68
"config.codeLens.enable": "Enable code lens.",
79
"config.color.mode": "Color mode.",
@@ -63,6 +65,7 @@
6365
"config.diagnostics.global-element": "Enable diagnostics to warn about global elements.",
6466
"config.diagnostics.global-in-nil-env": "Enable cannot use global variables ( `_ENV` is set to `nil`) diagnostics.",
6567
"config.diagnostics.globals": "Defined global variables.",
68+
"config.diagnostics.globalsRegex": "Find defined global variables using regex.",
6669
"config.diagnostics.groupFileStatus": "Modify the diagnostic needed file status in a group.\n\n* Opened: only diagnose opened files\n* Any: diagnose all files\n* None: disable this diagnostic\n\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately.\nOther settings will override individual settings without end of `!`.\n",
6770
"config.diagnostics.groupSeverity": "Modify the diagnostic severity in a group.\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.severity` separately.\nOther settings will override individual settings without end of `!`.\n",
6871
"config.diagnostics.ignoredFiles": "How to diagnose ignored files.",

package.nls.pt-br.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"command.addon_manager.open": "Lua: Open Addon Manager ...",
33
"command.exportDocument": "Lua: Export Document ...",
44
"command.reloadFFIMeta": "Lua: Reload luajit ffi meta",
5+
"command.startServer": "Lua: (debug) Start Language Server",
6+
"command.stopServer": "Lua: (debug) Stop Language Server",
57
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
68
"config.codeLens.enable": "Enable code lens.",
79
"config.color.mode": "Color mode.",
@@ -63,6 +65,7 @@
6365
"config.diagnostics.global-element": "Enable diagnostics to warn about global elements.",
6466
"config.diagnostics.global-in-nil-env": "不能使用全局变量( `_ENV` 被设置为了 `nil`)",
6567
"config.diagnostics.globals": "Defined global variables.",
68+
"config.diagnostics.globalsRegex": "Find defined global variables using regex.",
6669
"config.diagnostics.groupFileStatus": "Modify the diagnostic needed file status in a group.\n\n* Opened: only diagnose opened files\n* Any: diagnose all files\n* None: disable this diagnostic\n\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately.\nOther settings will override individual settings without end of `!`.\n",
6770
"config.diagnostics.groupSeverity": "Modify the diagnostic severity in a group.\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.severity` separately.\nOther settings will override individual settings without end of `!`.\n",
6871
"config.diagnostics.ignoredFiles": "How to diagnose ignored files.",

package.nls.zh-cn.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"command.addon_manager.open": "Lua: 打开插件管理器...",
33
"command.exportDocument": "Lua: 导出文档...",
44
"command.reloadFFIMeta": "Lua: 重新生成luajit的FFI模块C语言元数据",
5+
"command.startServer": "Lua: (debug) 启动服务器",
6+
"command.stopServer": "Lua: (debug) 停止服务器",
57
"config.addonManager.enable": "是否启用扩展的附加插件管理器(Addon Manager)",
68
"config.codeLens.enable": "启用代码度量。",
79
"config.color.mode": "着色模式。",
@@ -63,6 +65,7 @@
6365
"config.diagnostics.global-element": "Enable diagnostics to warn about global elements.",
6466
"config.diagnostics.global-in-nil-env": "不能使用全局变量( `_ENV` 被设置为了 `nil`)",
6567
"config.diagnostics.globals": "已定义的全局变量。",
68+
"config.diagnostics.globalsRegex": "Find defined global variables using regex.",
6669
"config.diagnostics.groupFileStatus": "批量修改一个组中的文件状态。\n\n* Opened: 只诊断打开的文件\n* Any: 诊断任何文件\n* None: 禁用此诊断\n\n设置为 `Fallback` 意味着组中的诊断由 `diagnostics.neededFileStatus` 单独设置。\n其他设置将覆盖单独设置,但是不会覆盖以 `!` 结尾的设置。\n",
6770
"config.diagnostics.groupSeverity": "批量修改一个组中的诊断等级。\n设置为 `Fallback` 意味着组中的诊断由 `diagnostics.severity` 单独设置。\n其他设置将覆盖单独设置,但是不会覆盖以 `!` 结尾的设置。\n",
6871
"config.diagnostics.ignoredFiles": "如何诊断被忽略的文件。",

package.nls.zh-tw.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"command.addon_manager.open": "Lua: Open Addon Manager ...",
33
"command.exportDocument": "Lua: Export Document ...",
44
"command.reloadFFIMeta": "Lua: Reload luajit ffi meta",
5+
"command.startServer": "Lua: (debug) Start Language Server",
6+
"command.stopServer": "Lua: (debug) Stop Language Server",
57
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
68
"config.codeLens.enable": "Enable code lens.",
79
"config.color.mode": "著色模式。",
@@ -63,6 +65,7 @@
6365
"config.diagnostics.global-element": "Enable diagnostics to warn about global elements.",
6466
"config.diagnostics.global-in-nil-env": "不能使用全域變數( `_ENV` 被設定為 `nil`)",
6567
"config.diagnostics.globals": "已定義的全域變數。",
68+
"config.diagnostics.globalsRegex": "Find defined global variables using regex.",
6669
"config.diagnostics.groupFileStatus": "批量修改一個組中的檔案狀態。\n\n* Opened: 只診斷打開的檔案\n* Any: 診斷所有檔案\n* None: 停用此診斷\n\n設定為 `Fallback` 意味著組中的診斷由 `diagnostics.neededFileStatus` 單獨設定。\n其他設定將覆蓋單獨設定,但是不會覆蓋以 `!` 結尾的設定。\n",
6770
"config.diagnostics.groupSeverity": "批量修改一個組中的診斷等級。\n設定為 `Fallback` 意味著組中的診斷由 `diagnostics.severity` 單獨設定。\n其他設定將覆蓋單獨設定,但是不會覆蓋以 `!` 結尾的設定。\n",
6871
"config.diagnostics.ignoredFiles": "如何診斷被忽略的檔案。",

package/package.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ return {
5252
},
5353
{
5454
command = "lua.startServer",
55-
title = "重启服务器",
55+
title = "%command.startServer%",
5656
},
5757
{
5858
command = "lua.stopServer",
59-
title = "停止服务器",
59+
title = "%command.stopServer%",
6060
}
6161
},
6262
menus = {

setting/schema-pt-br.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@
165165
"globals": {
166166
"$ref": "#/properties/diagnostics.globals"
167167
},
168+
"globalsRegex": {
169+
"$ref": "#/properties/diagnostics.globalsRegex"
170+
},
168171
"groupFileStatus": {
169172
"$ref": "#/properties/diagnostics.groupFileStatus"
170173
},
@@ -365,6 +368,15 @@
365368
"scope": "resource",
366369
"type": "array"
367370
},
371+
"diagnostics.globalsRegex": {
372+
"default": [],
373+
"items": {
374+
"type": "string"
375+
},
376+
"markdownDescription": "Find defined global variables using regex.",
377+
"scope": "resource",
378+
"type": "array"
379+
},
368380
"diagnostics.groupFileStatus": {
369381
"additionalProperties": false,
370382
"markdownDescription": "Modify the diagnostic needed file status in a group.\n\n* Opened: only diagnose opened files\n* Any: diagnose all files\n* None: disable this diagnostic\n\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately.\nOther settings will override individual settings without end of `!`.\n",

setting/schema-zh-cn.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@
165165
"globals": {
166166
"$ref": "#/properties/diagnostics.globals"
167167
},
168+
"globalsRegex": {
169+
"$ref": "#/properties/diagnostics.globalsRegex"
170+
},
168171
"groupFileStatus": {
169172
"$ref": "#/properties/diagnostics.groupFileStatus"
170173
},
@@ -365,6 +368,15 @@
365368
"scope": "resource",
366369
"type": "array"
367370
},
371+
"diagnostics.globalsRegex": {
372+
"default": [],
373+
"items": {
374+
"type": "string"
375+
},
376+
"markdownDescription": "Find defined global variables using regex.",
377+
"scope": "resource",
378+
"type": "array"
379+
},
368380
"diagnostics.groupFileStatus": {
369381
"additionalProperties": false,
370382
"markdownDescription": "批量修改一个组中的文件状态。\n\n* Opened: 只诊断打开的文件\n* Any: 诊断任何文件\n* None: 禁用此诊断\n\n设置为 `Fallback` 意味着组中的诊断由 `diagnostics.neededFileStatus` 单独设置。\n其他设置将覆盖单独设置,但是不会覆盖以 `!` 结尾的设置。\n",

setting/schema-zh-tw.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@
165165
"globals": {
166166
"$ref": "#/properties/diagnostics.globals"
167167
},
168+
"globalsRegex": {
169+
"$ref": "#/properties/diagnostics.globalsRegex"
170+
},
168171
"groupFileStatus": {
169172
"$ref": "#/properties/diagnostics.groupFileStatus"
170173
},
@@ -365,6 +368,15 @@
365368
"scope": "resource",
366369
"type": "array"
367370
},
371+
"diagnostics.globalsRegex": {
372+
"default": [],
373+
"items": {
374+
"type": "string"
375+
},
376+
"markdownDescription": "Find defined global variables using regex.",
377+
"scope": "resource",
378+
"type": "array"
379+
},
368380
"diagnostics.groupFileStatus": {
369381
"additionalProperties": false,
370382
"markdownDescription": "批量修改一個組中的檔案狀態。\n\n* Opened: 只診斷打開的檔案\n* Any: 診斷所有檔案\n* None: 停用此診斷\n\n設定為 `Fallback` 意味著組中的診斷由 `diagnostics.neededFileStatus` 單獨設定。\n其他設定將覆蓋單獨設定,但是不會覆蓋以 `!` 結尾的設定。\n",

setting/schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@
165165
"globals": {
166166
"$ref": "#/properties/diagnostics.globals"
167167
},
168+
"globalsRegex": {
169+
"$ref": "#/properties/diagnostics.globalsRegex"
170+
},
168171
"groupFileStatus": {
169172
"$ref": "#/properties/diagnostics.groupFileStatus"
170173
},
@@ -365,6 +368,15 @@
365368
"scope": "resource",
366369
"type": "array"
367370
},
371+
"diagnostics.globalsRegex": {
372+
"default": [],
373+
"items": {
374+
"type": "string"
375+
},
376+
"markdownDescription": "Find defined global variables using regex.",
377+
"scope": "resource",
378+
"type": "array"
379+
},
368380
"diagnostics.groupFileStatus": {
369381
"additionalProperties": false,
370382
"markdownDescription": "Modify the diagnostic needed file status in a group.\n\n* Opened: only diagnose opened files\n* Any: diagnose all files\n* None: disable this diagnostic\n\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately.\nOther settings will override individual settings without end of `!`.\n",

0 commit comments

Comments
 (0)