summaryrefslogtreecommitdiffstats
path: root/nvim/init.lua
diff options
context:
space:
mode:
authorBayram Kazik <48856944+bayramkzk@users.noreply.github.com>2024-08-25 00:31:43 +0300
committerGitHub <noreply@github.com>2024-08-24 17:31:43 -0400
commit96a5111f0502171ff36e66e576d2338ba0369dd7 (patch)
tree14dd802fb19a8075020cbf4279299240e6d40bb8 /nvim/init.lua
parenta13a1bb17b6ccea38c7a7c85c6d8ded040d83438 (diff)
downloaddots-96a5111f0502171ff36e66e576d2338ba0369dd7.tar.gz
Include visual mode in LSP code action keymap (#1060) (#1064)
Diffstat (limited to 'nvim/init.lua')
-rw-r--r--nvim/init.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/nvim/init.lua b/nvim/init.lua
index 41b5a97..13ea93a 100644
--- a/nvim/init.lua
+++ b/nvim/init.lua
@@ -316,7 +316,7 @@ require('lazy').setup({
-- Document existing key chains
require('which-key').add {
- { '<leader>c', group = '[C]ode' },
+ { '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
@@ -507,8 +507,9 @@ require('lazy').setup({
--
-- 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.
- local map = function(keys, func, desc)
- vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
+ local map = function(keys, func, desc, mode)
+ mode = mode or 'n'
+ vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
-- Jump to the definition of the word under your cursor.
@@ -542,7 +543,7 @@ require('lazy').setup({
-- 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.
- 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.
-- For example, in C this would take you to the header.