diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-07-16 09:50:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-07-16 09:50:50 +0800 |
commit | e90b4d2aa2aa02ac55ca67a1be122267531ee658 (patch) | |
tree | cbdb640fb42f9036b0fe1239d74bbfbabbee99ec | |
parent | b194e1dcc6baff0274051a957d345366dd941977 (diff) | |
download | lua-language-server-e90b4d2aa2aa02ac55ca67a1be122267531ee658.zip |
close #62 支持禁用诊断
-rw-r--r-- | package.json | 6 | ||||
-rw-r--r-- | package.nls.json | 1 | ||||
-rw-r--r-- | package.nls.zh-cn.json | 1 | ||||
-rw-r--r-- | server/src/config.lua | 1 | ||||
-rw-r--r-- | server/src/service.lua | 4 | ||||
-rw-r--r-- | server/test/build_package.lua | 8 |
6 files changed, 21 insertions, 0 deletions
diff --git a/package.json b/package.json index 1d8ad9e1..dbbb8d76 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,12 @@ "scope": "resource", "type": "array" }, + "Lua.diagnostics.enable": { + "default": true, + "markdownDescription": "%config.diagnostics.enable%", + "scope": "resource", + "type": "boolean" + }, "Lua.diagnostics.globals": { "items": "string", "markdownDescription": "%config.diagnostics.globals%", diff --git a/package.nls.json b/package.nls.json index 9362a31a..4403a790 100644 --- a/package.nls.json +++ b/package.nls.json @@ -1,5 +1,6 @@ { "config.diagnostics.disable": "Disabled diagnostic (Use code in hover brackets).\n```json\n\"Lua.diagnostics.disable\" : [\n \"unused-local\",\n \"lowercase-global\"\n]\n```\n", + "config.diagnostics.enable": "Enable diagnostics.", "config.diagnostics.globals": "Defined global variables.\n```json\n\"Lua.diagnostics.globals\" : [\n \"GLOBAL1\",\n \"GLOBAL2\"\n]\n```\n", "config.diagnostics.severity": "Modified diagnostic severity.\n```json\n\"Lua.diagnostics.severity\" : {\n \"redefined-local\" : \"Warning\",\n \"emmy-lua\" : \"Hint\"\n}\n```\n", "config.runtime.path": "`package.path`", diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json index 8cb57031..a8f3e102 100644 --- a/package.nls.zh-cn.json +++ b/package.nls.zh-cn.json @@ -1,5 +1,6 @@ { "config.diagnostics.disable": "禁用的诊断(使用浮框括号内的代码)。\n```json\n\"Lua.diagnostics.disable\" : [\n \"unused-local\",\n \"lowercase-global\"\n]\n```\n", + "config.diagnostics.enable": "启用诊断。", "config.diagnostics.globals": "已定义的全局变量。\n```json\n\"Lua.diagnostics.globals\" : [\n \"GLOBAL1\",\n \"GLOBAL2\"\n]\n```\n", "config.diagnostics.severity": "修改诊断等级。\n```json\n\"Lua.diagnostics.severity\" : {\n \"redefined-local\" : \"Warning\",\n \"emmy-lua\" : \"Hint\"\n}\n```\n", "config.runtime.path": "`package.path`", diff --git a/server/src/config.lua b/server/src/config.lua index eded1c9d..ec01bd08 100644 --- a/server/src/config.lua +++ b/server/src/config.lua @@ -100,6 +100,7 @@ local ConfigTemplate = { }, Array(String)}, }, diagnostics = { + enable = {true, Boolean}, globals = {{}, Str2Hash ';'}, disable = {{}, Str2Hash ';'}, severity = { diff --git a/server/src/service.lua b/server/src/service.lua index fb8c3123..9242a61d 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -536,6 +536,10 @@ end ---@param uri uri function mt:doDiagnostics(uri) + if not config.config.diagnostics.enable then + self._needDiagnostics[uri] = nil + return + end if not self._needDiagnostics[uri] then return end diff --git a/server/test/build_package.lua b/server/test/build_package.lua index aba97e56..e987adca 100644 --- a/server/test/build_package.lua +++ b/server/test/build_package.lua @@ -62,6 +62,12 @@ local package = { "?/?.lua" } }, + ["Lua.diagnostics.enable"] = { + scope = 'resource', + type = 'boolean', + default = true, + markdownDescription = "%config.diagnostics.enable%" + }, ["Lua.diagnostics.disable"] = { scope = "resource", type = "array", @@ -203,6 +209,7 @@ local example = { io.save(ROOT:parent_path() / 'package.nls.json', json.encode { ["config.runtime.version"] = "Lua runtime version.", ["config.runtime.path"] = "`package.path`", + ["config.diagnostics.enable"] = "Enable diagnostics.", ["config.diagnostics.disable"] = "Disabled diagnostic (Use code in hover brackets).\n" .. example.disable, ["config.diagnostics.globals"] = "Defined global variables.\n" .. example.globals, ["config.diagnostics.severity"] = "Modified diagnostic severity.\n" .. example.severity, @@ -222,6 +229,7 @@ The following example shows loaded files in `C:/lua` and `../lib` ,exclude `../l io.save(ROOT:parent_path() / 'package.nls.zh-cn.json', json.encode { ["config.runtime.version"] = "Lua运行版本。", ["config.runtime.path"] = "`package.path`", + ["config.diagnostics.enable"] = "启用诊断。", ["config.diagnostics.disable"] = "禁用的诊断(使用浮框括号内的代码)。\n" .. example.disable, ["config.diagnostics.globals"] = "已定义的全局变量。\n" .. example.globals, ["config.diagnostics.severity"] = "修改诊断等级。\n" .. example.severity, |