summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruhziel <uhziel@gmail.com>2020-12-15 18:17:18 +0800
committeruhziel <uhziel@gmail.com>2020-12-15 18:17:18 +0800
commit295d45c0e8b781e056138e869c5c32e876272b9c (patch)
treeaef6634f884e3482c971445ddfa5f030d5ba9323
parentf3ec5825e3c6a8090a020097e088f26718c316bb (diff)
downloadlua-language-server-295d45c0e8b781e056138e869c5c32e876272b9c.zip
指定诊断类型可以配置只分析打开的文件还是全项目,初版还需要支持vscode配置
-rw-r--r--script/config.lua4
-rw-r--r--script/core/diagnostics/init.lua12
-rw-r--r--script/proto/define.lua46
3 files changed, 47 insertions, 15 deletions
diff --git a/script/config.lua b/script/config.lua
index c9d8e075..74f2ff4e 100644
--- a/script/config.lua
+++ b/script/config.lua
@@ -113,6 +113,10 @@ local ConfigTemplate = {
util.deepCopy(define.DiagnosticDefaultSeverity),
Hash(String, String),
},
+ neededFileStatus = {
+ util.deepCopy(define.DiagnosticDefaultNeededFileStatus),
+ Hash(String, String),
+ },
workspaceDelay = {0, Integer},
workspaceRate = {100, Integer},
},
diff --git a/script/core/diagnostics/init.lua b/script/core/diagnostics/init.lua
index 510b57ea..15884758 100644
--- a/script/core/diagnostics/init.lua
+++ b/script/core/diagnostics/init.lua
@@ -22,14 +22,10 @@ local function check(uri, name, results)
end
local level = config.config.diagnostics.severity[name]
or define.DiagnosticDefaultSeverity[name]
- if not files.isOpen(uri) then
- if level == 'Hint' then
- return
- end
- -- TODO
- if name == 'undefined-field' then
- return
- end
+
+ local neededFileStatus = define.DiagnosticDefaultNeededFileStatus[name]
+ if neededFileStatus == 'Opened' and not files.isOpen(uri) then
+ return
end
local severity = define.DiagnosticSeverity[level]
local clock = os.clock()
diff --git a/script/proto/define.lua b/script/proto/define.lua
index 6ddcd3a7..88493abe 100644
--- a/script/proto/define.lua
+++ b/script/proto/define.lua
@@ -168,6 +168,45 @@ m.DiagnosticDefaultSeverity = {
['duplicate-doc-field'] = 'Warning',
}
+-- 文件状态
+m.FileStatus = {
+ Any = 1,
+ Opened = 2,
+}
+
+--- 诊断类型与需要的文件状态(可以控制只分析打开的文件、还是所有文件)
+m.DiagnosticDefaultNeededFileStatus = {
+ ['unused-local'] = 'Opened',
+ ['unused-function'] = 'Opened',
+ ['undefined-global'] = 'Any',
+ ['undefined-field'] = 'Opened',
+ ['global-in-nil-env'] = 'Any',
+ ['unused-label'] = 'Opened',
+ ['unused-vararg'] = 'Opened',
+ ['trailing-space'] = 'Opened',
+ ['redefined-local'] = 'Opened',
+ ['newline-call'] = 'Any',
+ ['newfield-call'] = 'Any',
+ ['redundant-parameter'] = 'Opened',
+ ['ambiguity-1'] = 'Any',
+ ['lowercase-global'] = 'Any',
+ ['undefined-env-child'] = 'Any',
+ ['duplicate-index'] = 'Any',
+ ['empty-block'] = 'Opened',
+ ['redundant-value'] = 'Opened',
+ ['code-after-break'] = 'Opened',
+ ['unbalanced-assignments'] = 'Any',
+
+ ['duplicate-doc-class'] = 'Any',
+ ['undefined-doc-class'] = 'Any',
+ ['undefined-doc-name'] = 'Any',
+ ['circle-doc-class'] = 'Any',
+ ['undefined-doc-param'] = 'Any',
+ ['duplicate-doc-param'] = 'Any',
+ ['doc-field-no-class'] = 'Any',
+ ['duplicate-doc-field'] = 'Any',
+}
+
--- 诊断报告标签
m.DiagnosticTag = {
Unnecessary = 1,
@@ -221,13 +260,6 @@ m.CompletionItemKind = {
TypeParameter = 25,
}
-m.DiagnosticSeverity = {
- Error = 1,
- Warning = 2,
- Information = 3,
- Hint = 4,
-}
-
m.ErrorCodes = {
-- Defined by JSON RPC
ParseError = -32700,