summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/method/init.lua1
-rw-r--r--server/src/method/initialize.lua1
-rw-r--r--server/src/method/textDocument/codeAction.lua32
3 files changed, 34 insertions, 0 deletions
diff --git a/server/src/method/init.lua b/server/src/method/init.lua
index 588129be..2fe9f4b1 100644
--- a/server/src/method/init.lua
+++ b/server/src/method/init.lua
@@ -8,6 +8,7 @@ init 'exit'
init 'initialize'
init 'initialized'
init 'shutdown'
+init 'textDocument/codeAction'
init 'textDocument/completion'
init 'textDocument/definition'
init 'textDocument/didOpen'
diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua
index 60e8ee1e..5148e24b 100644
--- a/server/src/method/initialize.lua
+++ b/server/src/method/initialize.lua
@@ -18,6 +18,7 @@ return function (lsp)
renameProvider = true,
documentSymbolProvider = true,
documentHighlightProvider = true,
+ codeActionProvider = true,
signatureHelpProvider = {
triggerCharacters = { '(', ',' },
},
diff --git a/server/src/method/textDocument/codeAction.lua b/server/src/method/textDocument/codeAction.lua
new file mode 100644
index 00000000..4c4e85a3
--- /dev/null
+++ b/server/src/method/textDocument/codeAction.lua
@@ -0,0 +1,32 @@
+return function (lsp, params)
+ log.debug(table.dump(params))
+ local uri = params.textDocument.uri
+ local result = {}
+
+ for _, data in ipairs(params.context.diagnostics) do
+ if data.code then
+ result[#result+1] = {
+ title = ('禁用诊断(%s)'):format(data.code),
+ kind = 'quickfix',
+ diagnostics = {data},
+ command = {
+ title = '测试',
+ command = 'config',
+ arguments = {
+ key = {'diagnostics', 'disable'},
+ action = 'add',
+ value = data.code,
+ }
+ }
+ }
+ end
+ end
+
+ log.debug(table.dump(result))
+
+ if #result == 0 then
+ return nil
+ end
+
+ return result
+end