Skip to content

Commit 043333a

Browse files
theopnfse-wd
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 88049f8 commit 043333a

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
@@ -338,11 +338,7 @@ require('lazy').setup({
338338

339339
-- Document existing key chains
340340
spec = {
341-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
342-
{ '<leader>d', group = '[D]ocument' },
343-
{ '<leader>r', group = '[R]ename' },
344341
{ '<leader>s', group = '[S]earch' },
345-
{ '<leader>w', group = '[W]orkspace' },
346342
{ '<leader>t', group = '[T]oggle' },
347343
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
348344
},
@@ -534,42 +530,42 @@ require('lazy').setup({
534530
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
535531
end
536532

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)