Skip to content

Commit b1c9ab3

Browse files
theopnaudunhov
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 2bb5d71 commit b1c9ab3

1 file changed

Lines changed: 23 additions & 27 deletions

File tree

init.lua

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

254254
-- Document existing key chains
255255
spec = {
256-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
257-
{ '<leader>d', group = '[D]ocument' },
258-
{ '<leader>r', group = '[R]ename' },
259256
{ '<leader>s', group = '[S]earch' },
260-
{ '<leader>w', group = '[W]orkspace' },
261257
{ '<leader>t', group = '[T]oggle' },
262258
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
263259
},
@@ -449,42 +445,42 @@ require('lazy').setup({
449445
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
450446
end
451447

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

457456
-- Find references for the word under your cursor.
458-
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
457+
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
459458

460459
-- Jump to the implementation of the word under your cursor.
461460
-- Useful when your language has ways of declaring types without an actual implementation.
462-
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
461+
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
463462

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

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

473476
-- Fuzzy find all the symbols in your current workspace.
474477
-- Similar to document symbols, except searches over your entire project.
475-
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
476-
477-
-- Rename the variable under your cursor.
478-
-- Most Language Servers support renaming across files, etc.
479-
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
480-
481-
-- Execute a code action, usually your cursor needs to be on top of an error
482-
-- or a suggestion from your LSP for this to activate.
483-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
478+
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
484479

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

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

0 commit comments

Comments
 (0)