Skip to content

Commit 28e567b

Browse files
theopnDerFrZocker
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 7d8b4ec commit 28e567b

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

init.lua

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,7 @@ require('lazy').setup({
340340

341341
-- Document existing key chains
342342
spec = {
343-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
344-
{ '<leader>d', group = '[D]ocument' },
345-
{ '<leader>r', group = '[R]ename' },
346343
{ '<leader>s', group = '[S]earch' },
347-
{ '<leader>w', group = '[W]orkspace' },
348344
{ '<leader>t', group = '[T]oggle' },
349345
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
350346
},
@@ -536,42 +532,42 @@ require('lazy').setup({
536532
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
537533
end
538534

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

544543
-- Find references for the word under your cursor.
545-
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
544+
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
546545

547546
-- Jump to the implementation of the word under your cursor.
548547
-- Useful when your language has ways of declaring types without an actual implementation.
549-
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
548+
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
550549

551-
-- Jump to the type of the word under your cursor.
552-
-- Useful when you're not sure what type a variable is and you want to see
553-
-- the definition of its *type*, not where it was *defined*.
554-
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
550+
-- Jump to the definition of the word under your cursor.
551+
-- This is where a variable was first declared, or where a function is defined, etc.
552+
-- To jump back, press <C-t>.
553+
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
554+
555+
-- WARN: This is not Goto Definition, this is Goto Declaration.
556+
-- For example, in C this would take you to the header.
557+
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
555558

556559
-- Fuzzy find all the symbols in your current document.
557560
-- Symbols are things like variables, functions, types, etc.
558-
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
561+
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
559562

560563
-- Fuzzy find all the symbols in your current workspace.
561564
-- Similar to document symbols, except searches over your entire project.
562-
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
563-
564-
-- Rename the variable under your cursor.
565-
-- Most Language Servers support renaming across files, etc.
566-
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
567-
568-
-- Execute a code action, usually your cursor needs to be on top of an error
569-
-- or a suggestion from your LSP for this to activate.
570-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
565+
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
571566

572-
-- WARN: This is not Goto Definition, this is Goto Declaration.
573-
-- For example, in C this would take you to the header.
574-
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
567+
-- Jump to the type of the word under your cursor.
568+
-- Useful when you're not sure what type a variable is and you want to see
569+
-- the definition of its *type*, not where it was *defined*.
570+
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
575571

576572
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
577573
---@param client vim.lsp.Client

0 commit comments

Comments
 (0)