diff options
Diffstat (limited to 'server/src/method/textDocument/publishDiagnostics.lua')
-rw-r--r-- | server/src/method/textDocument/publishDiagnostics.lua | 22 |
1 files changed, 22 insertions, 0 deletions
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 |