Skip to content

Commit 1d22050

Browse files
committed
Include visual mode in LSP code action keymap (#1060)
1 parent 4e326fa commit 1d22050

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

init.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ require('lazy').setup({
279279

280280
-- Document existing key chains
281281
require('which-key').add {
282-
{ '<leader>c', group = '[C]ode' },
282+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
283283
{ '<leader>d', group = '[D]ocument' },
284284
{ '<leader>r', group = '[R]ename' },
285285
{ '<leader>s', group = '[S]earch' },
@@ -470,8 +470,8 @@ require('lazy').setup({
470470
--
471471
-- In this case, we create a function that lets us more easily define mappings specific
472472
-- for LSP related items. It sets the mode, buffer and description for us each time.
473-
local map = function(keys, func, desc)
474-
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
473+
local map = function(keys, func, desc, mode = 'n')
474+
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
475475
end
476476

477477
-- Jump to the definition of the word under your cursor.
@@ -505,7 +505,7 @@ require('lazy').setup({
505505

506506
-- Execute a code action, usually your cursor needs to be on top of an error
507507
-- or a suggestion from your LSP for this to activate.
508-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
508+
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
509509

510510
-- WARN: This is not Goto Definition, this is Goto Declaration.
511511
-- For example, in C this would take you to the header.

0 commit comments

Comments
 (0)