diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-28 13:03:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-28 13:03:58 +0800 |
commit | b4bbfce903852d6c837f9a9a06f00406a5fc86a5 (patch) | |
tree | 73985e026064eec81e92779c5c814dd67c768477 /server/src/method | |
parent | b5b11853e543e8da30270bd25fbc9376c20fc398 (diff) | |
download | lua-language-server-b4bbfce903852d6c837f9a9a06f00406a5fc86a5.zip |
codeAction的第一步
Diffstat (limited to 'server/src/method')
-rw-r--r-- | server/src/method/init.lua | 1 | ||||
-rw-r--r-- | server/src/method/initialize.lua | 1 | ||||
-rw-r--r-- | server/src/method/textDocument/codeAction.lua | 32 |
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 |