summaryrefslogtreecommitdiff
path: root/script/core/code-action.lua
diff options
context:
space:
mode:
authorCppCXY <812125110@qq.com>2022-05-24 11:57:39 +0800
committerCppCXY <812125110@qq.com>2022-05-24 11:57:39 +0800
commitb51c930f3cca060b10ab724666c9f5265cefd517 (patch)
treebdc5296f83672c9694bc5d113c0202e126442e05 /script/core/code-action.lua
parentf0f80fdf1b5c83467687541ffda36cabb8f9bd62 (diff)
downloadlua-language-server-b51c930f3cca060b10ab724666c9f5265cefd517.zip
重置代码,取消多余的提交
Diffstat (limited to 'script/core/code-action.lua')
-rw-r--r--script/core/code-action.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/script/core/code-action.lua b/script/core/code-action.lua
index 6bba0a82..09b271c6 100644
--- a/script/core/code-action.lua
+++ b/script/core/code-action.lua
@@ -350,6 +350,51 @@ local function solveAwaitInSync(uri, diag, results)
}
end
+local function solveSpell(uri, diag, results)
+ local spell = require 'provider.spell'
+ local word = diag.data
+ if word == nil then
+ return
+ end
+
+ results[#results+1] = {
+ title = lang.script('ACTION_ADD_DICT', word),
+ kind = 'quickfix',
+ command = {
+ title = lang.script.COMMAND_ADD_DICT,
+ command = 'lua.setConfig',
+ arguments = {
+ {
+ key = 'Lua.spell.dict',
+ action = 'add',
+ value = word,
+ uri = uri,
+ }
+ }
+ }
+ }
+
+ local suggests = spell.getSpellSuggest(word)
+ for _, suggest in ipairs(suggests) do
+ results[#results+1] = {
+ title = suggest,
+ kind = 'quickfix',
+ edit = {
+ changes = {
+ [uri] = {
+ {
+ start = converter.unpackPosition(uri, diag.range.start),
+ finish = converter.unpackPosition(uri, diag.range["end"]),
+ newText = suggest
+ }
+ }
+ }
+ }
+ }
+ end
+
+end
+
local function solveDiagnostic(uri, diag, start, results)
if diag.source == lang.script.DIAG_SYNTAX_CHECK then
solveSyntax(uri, diag, results)
@@ -370,6 +415,8 @@ local function solveDiagnostic(uri, diag, start, results)
solveTrailingSpace(uri, diag, results)
elseif diag.code == 'await-in-sync' then
solveAwaitInSync(uri, diag, results)
+ elseif diag.code == 'spell-check' then
+ solveSpell(uri, diag, results)
end
disableDiagnostic(uri, diag.code, start, results)
end