Skip to content

Commit d62977c

Browse files
theopnscrewage
authored andcommitted
Change LSP Keybindings to Match the Default gr Bindings Introduced in Neovim 0.11 (nvim-lua#1427)
* refactor: change LSP keybindings to the default gr bindings introduced in 0.11 * refactor: modify existing LSP functions to follow convention
1 parent cb7a31c commit d62977c

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

init.lua

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,7 @@ require('lazy').setup({
383383

384384
-- Document existing key chains
385385
spec = {
386-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
387-
{ '<leader>d', group = '[D]ocument' },
388-
{ '<leader>r', group = '[R]ename' },
389386
{ '<leader>s', group = '[S]earch' },
390-
{ '<leader>w', group = '[W]orkspace' },
391387
{ '<leader>t', group = '[T]oggle' },
392388
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
393389
},
@@ -580,17 +576,37 @@ require('lazy').setup({
580576
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
581577
end
582578

583-
-- Jump to the definition of the word under your cursor.
584-
-- This is where a variable was first declared, or where a function is defined, etc.
585-
-- To jump back, press <C-t>.
586-
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
579+
-- Rename the variable under your cursor.
580+
-- Most Language Servers support renaming across files, etc.
581+
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
582+
583+
-- Execute a code action, usually your cursor needs to be on top of an error
584+
-- or a suggestion from your LSP for this to activate.
585+
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
587586

588587
-- Find references for the word under your cursor.
589-
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
588+
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
590589

591590
-- Jump to the implementation of the word under your cursor.
592591
-- Useful when your language has ways of declaring types without an actual implementation.
593-
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
592+
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
593+
594+
-- Jump to the definition of the word under your cursor.
595+
-- This is where a variable was first declared, or where a function is defined, etc.
596+
-- To jump back, press <C-t>.
597+
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
598+
599+
-- WARN: This is not Goto Definition, this is Goto Declaration.
600+
-- For example, in C this would take you to the header.
601+
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
602+
603+
-- Fuzzy find all the symbols in your current document.
604+
-- Symbols are things like variables, functions, types, etc.
605+
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
606+
607+
-- Fuzzy find all the symbols in your current workspace.
608+
-- Similar to document symbols, except searches over your entire project.
609+
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
594610

595611
-- Jump to the type of the word under your cursor.
596612
-- Useful when you're not sure what type a variable is and you want to see

0 commit comments

Comments
 (0)