simpily codeaction and range_code_action keymapping and code

neovim_0.6^2
ray-x 2 years ago
parent 3ad93531b5
commit 27442d2784

@ -429,7 +429,7 @@ In `playground` folder, there is a `init.lua` and source code for you to play wi
| n | K | hover doc |
| n | \<Space\>ca | code action (when you see 🏏 ) |
| n | \<Space\>la | code lens action (when you see a codelens indicator) |
| v | \<Space\>cA | range code action (when you see 🏏 ) |
| v | \<Space\>ca | range code action (when you see 🏏 ) |
| n | \<Space\>rn | rename with floating window |
| n | \<Leader\>re | rename (lsp default) |
| n | \<Leader\>gi | hierarchy incoming calls |

@ -173,16 +173,27 @@ end
code_action.range_code_action = function(startpos, endpos)
local context = {}
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
local params = util.make_given_range_params(startpos, endpos)
local bufnr = vim.api.nvim_get_current_buf()
startpos = startpos or api.nvim_buf_get_mark(bufnr, '<')
endpos = endpos or api.nvim_buf_get_mark(bufnr, '>')
log(startpos, endpos)
local params = vim.lsp.util.make_given_range_params(startpos, endpos)
params.context = context
local original_select = vim.ui.select
vim.ui.select = require('guihua.gui').select
local original_input = vim.ui.input
vim.ui.input = require('guihua.input').input
vim.lsp.buf.range_code_action(context, startpos, endpos)
vim.defer_fn(function()
vim.ui.select = original_select
end, 1000)
vim.defer_fn(function()
vim.ui.input = original_input
end, 1000)
end
code_action.code_action_prompt = function()

@ -36,7 +36,7 @@ local key_maps = {
{ key = '<Leader>ct', func = "require('navigator.ctags').ctags()" },
{ key = 'K', func = 'hover({ popup_opts = { border = single, max_width = 80 }})' },
{ key = '<Space>ca', mode = 'n', func = "require('navigator.codeAction').code_action()" },
{ key = '<Space>cA', mode = 'v', func = 'range_code_action()' },
{ key = '<Space>ca', mode = 'v', func = "require('navigator.codeAction').range_code_action()" },
-- { key = '<Leader>re', func = 'rename()' },
{ key = '<Space>rn', func = "require('navigator.rename').rename()" },
{ key = '<Leader>gi', func = 'incoming_calls()' },

Loading…
Cancel
Save