diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2021-09-28 23:04:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 14:04:01 -0700 |
commit | ec4731d982031e363a59efd4566fc72234bb43c8 (patch) | |
tree | c0f6dabcdd7c0ae86da4fd74da44dd80abe2dba3 /runtime/lua/vim/lsp/handlers.lua | |
parent | 3507d58dfb87923aa4031cbefaf1ef576a45dcaf (diff) | |
download | rneovim-ec4731d982031e363a59efd4566fc72234bb43c8.tar.gz rneovim-ec4731d982031e363a59efd4566fc72234bb43c8.tar.bz2 rneovim-ec4731d982031e363a59efd4566fc72234bb43c8.zip |
feat(lsp): add codeAction/resolve support (#15818)
Closes https://github.com/neovim/neovim/issues/15339 and https://github.com/neovim/neovim/issues/15828
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index def83a7320..eff27807be 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -3,7 +3,6 @@ local protocol = require 'vim.lsp.protocol' local util = require 'vim.lsp.util' local vim = vim local api = vim.api -local buf = require 'vim.lsp.buf' local M = {} @@ -109,53 +108,6 @@ M['client/registerCapability'] = function(_, _, ctx) return vim.NIL end ---see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction -M['textDocument/codeAction'] = function(_, result, ctx) - if result == nil or vim.tbl_isempty(result) then - print("No code actions available") - return - end - - ---@private - local function on_user_choice(action) - if not action then - return - end - -- textDocument/codeAction can return either Command[] or CodeAction[] - -- - -- CodeAction - -- ... - -- edit?: WorkspaceEdit -- <- must be applied before command - -- command?: Command - -- - -- Command: - -- title: string - -- command: string - -- arguments?: any[] - -- - if action.edit then - util.apply_workspace_edit(action.edit) - end - if action.command then - local command = type(action.command) == 'table' and action.command or action - local fn = vim.lsp.commands[command.command] - if fn then - fn(command, ctx) - else - buf.execute_command(command) - end - end - end - - vim.ui.select(result, { - prompt = 'Code actions:', - format_item = function(action) - local title = action.title:gsub('\r\n', '\\r\\n') - return title:gsub('\n', '\\n') - end, - }, on_user_choice) -end - --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit M['workspace/applyEdit'] = function(_, workspace_edit) if not workspace_edit then return end |