summaryrefslogtreecommitdiff
path: root/server/src/method
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/method')
-rw-r--r--server/src/method/textDocument/completion.lua2
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua22
2 files changed, 22 insertions, 2 deletions
diff --git a/server/src/method/textDocument/completion.lua b/server/src/method/textDocument/completion.lua
index 3a8a2e6b..81ef1446 100644
--- a/server/src/method/textDocument/completion.lua
+++ b/server/src/method/textDocument/completion.lua
@@ -23,7 +23,6 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- log.debug(table.dump(params.position))
local items = matcher.completion(vm, position)
if not items then
return nil
@@ -43,6 +42,5 @@ return function (lsp, params)
isIncomplete = true,
items = items,
}
- log.debug(table.dump(response))
return response
end
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua
index 5f71d475..1186374d 100644
--- a/server/src/method/textDocument/publishDiagnostics.lua
+++ b/server/src/method/textDocument/publishDiagnostics.lua
@@ -75,10 +75,27 @@ local function createInfo(data, lines)
return diagnostic
end
+local function buildError(err, lines)
+ local diagnostic = {
+ source = 'Lua Language Server',
+ message = 'Error',
+ }
+ if err.level == 'error' then
+ diagnostic.severity = DiagnosticSeverity.Error
+ else
+ diagnostic.severity = DiagnosticSeverity.Warning
+ end
+ local range = getRange(err.pos, err.pos, lines)
+ range['end'].character = 9999
+ diagnostic.range = range
+ return diagnostic
+end
+
return function (lsp, params)
local vm = params.vm
local lines = params.lines
local uri = params.uri
+ local errs = lsp:getAstErrors(uri)
local diagnostics = {}
if vm then
@@ -87,6 +104,11 @@ return function (lsp, params)
diagnostics[#diagnostics+1] = createInfo(data, lines)
end
end
+ if errs then
+ for _, err in ipairs(errs) do
+ diagnostics[#diagnostics+1] = buildError(err, lines)
+ end
+ end
return diagnostics
end