summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-05 17:48:52 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-05 17:48:52 +0800
commit26138568cd004fa922f0aa7d96052ebd28ca63ee (patch)
treeb08b4bd070d54bb24738f4c4c00ffc0f2bee1bd4 /script/core
parent41b72b3c9915bbda4d7ae0e456d45791cc76b5ee (diff)
downloadlua-language-server-26138568cd004fa922f0aa7d96052ebd28ca63ee.zip
completion of `doc.diagnostic`
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 407a0e98..613ca062 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -21,6 +21,13 @@ local furi = require 'file-uri'
local rpath = require 'workspace.require-path'
local lang = require 'language'
+local DiagnosticModes = {
+ 'disable-next-line',
+ 'disable-line',
+ 'disable',
+ 'enable',
+}
+
local stackID = 0
local stacks = {}
local function stack(callback)
@@ -1467,6 +1474,7 @@ local function tryLuaDocCate(word, results)
'meta',
'version',
'see',
+ 'diagnostic',
} do
if matchKey(word, docType) then
results[#results+1] = {
@@ -1568,6 +1576,35 @@ local function tryLuaDocBySource(ast, offset, source, results)
end
end
return true
+ elseif source.type == 'doc.diagnostic' then
+ for _, mode in ipairs(DiagnosticModes) do
+ if matchKey(source.mode, mode) then
+ results[#results+1] = {
+ label = mode,
+ kind = define.CompletionItemKind.Enum,
+ textEdit = {
+ start = source.start,
+ finish = source.start + #source.mode - 1,
+ newText = mode,
+ },
+ }
+ end
+ end
+ return true
+ elseif source.type == 'doc.diagnostic.name' then
+ for name in pairs(define.DiagnosticDefaultSeverity) do
+ if matchKey(source[1], name) then
+ results[#results+1] = {
+ label = name,
+ kind = define.CompletionItemKind.Value,
+ textEdit = {
+ start = source.start,
+ finish = source.start + #source[1] - 1,
+ newText = name,
+ },
+ }
+ end
+ end
end
return false
end
@@ -1632,6 +1669,20 @@ local function tryLuaDocByErr(ast, offset, err, docState, results)
}
end
end
+ elseif err.type == 'LUADOC_MISS_DIAG_MODE' then
+ for _, mode in ipairs(DiagnosticModes) do
+ results[#results+1] = {
+ label = mode,
+ kind = define.CompletionItemKind.Enum,
+ }
+ end
+ elseif err.type == 'LUADOC_MISS_DIAG_NAME' then
+ for name in pairs(define.DiagnosticDefaultSeverity) do
+ results[#results+1] = {
+ label = name,
+ kind = define.CompletionItemKind.Value,
+ }
+ end
end
end