Merge 'upstream' Include visual mode in LSP code action keymap

This commit is contained in:
Damjan 9000 2024-08-25 11:03:03 +02:00
commit 06929799f0
2 changed files with 5 additions and 4 deletions

View File

@ -67,8 +67,9 @@ return {
-- --
-- In this case, we create a function that lets us more easily define mappings specific -- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time. -- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function(keys, func, desc) local map = function(keys, func, desc, mode)
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end end
-- Jump to the definition of the word under your cursor. -- Jump to the definition of the word under your cursor.
@ -102,7 +103,7 @@ return {
-- Execute a code action, usually your cursor needs to be on top of an error -- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate. -- or a suggestion from your LSP for this to activate.
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
-- WARN: This is not Goto Definition, this is Goto Declaration. -- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header. -- For example, in C this would take you to the header.

View File

@ -59,7 +59,7 @@ return {
-- Document existing key chains -- Document existing key chains
require('which-key').add { require('which-key').add {
{ '<leader>c', group = '[C]ode' }, { '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' }, { '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' }, { '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' }, { '<leader>s', group = '[S]earch' },