diff options
-rw-r--r-- | .vscode/settings.json | 14 | ||||
-rw-r--r-- | server/src/method/textDocument/codeAction.lua | 25 |
2 files changed, 28 insertions, 11 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e0261e8..99940caf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,10 @@ { - "Lua.diagnostics.globals": [ - "TEST", - "ERR", - "OUT", - "IN" - ] + "Lua.diagnostics.globals" : [ + "TEST", + "ERR", + "OUT", + "IN", + "log", + "ac" + ] } diff --git a/server/src/method/textDocument/codeAction.lua b/server/src/method/textDocument/codeAction.lua index e2ff2e50..c61ad88f 100644 --- a/server/src/method/textDocument/codeAction.lua +++ b/server/src/method/textDocument/codeAction.lua @@ -18,11 +18,7 @@ local function disableDiagnostic(lsp, uri, data, callback) } end -local function solveUndefinedGlobal(lsp, uri, data, callback) - local vm, lines, text = lsp:getVM(uri) - if not vm then - return - end +local function addGlobal(lines, text, data, callback) local start = lines:position(data.range.start.line + 1, data.range.start.character + 1) local finish = lines:position(data.range['end'].line + 1, data.range['end'].character) local name = text:sub(start, finish) @@ -46,6 +42,22 @@ local function solveUndefinedGlobal(lsp, uri, data, callback) } end +local function solveUndefinedGlobal(lsp, uri, data, callback) + local vm, lines, text = lsp:getVM(uri) + if not vm then + return + end + addGlobal(lines, text, data, callback) +end + +local function solveLowercaseGlobal(lsp, uri, data, callback) + local vm, lines, text = lsp:getVM(uri) + if not vm then + return + end + addGlobal(lines, text, data, callback) +end + local function solveTrailingSpace(lsp, uri, data, callback) callback { title = lang.script.ACTION_REMOVE_SPACE, @@ -116,6 +128,9 @@ local function solveDiagnostic(lsp, uri, data, callback) if data.code == 'ambiguity-1' then solveAmbiguity1(lsp, uri, data, callback) end + if data.code == 'lowercase-global' then + solveLowercaseGlobal(lsp, uri, data, callback) + end disableDiagnostic(lsp, uri, data, callback) end |