Merge pull request #25 from nbur4556/redefine-lsp-shortcuts
Redefine lsp shortcuts
This commit is contained in:
commit
3364f2e297
|
|
@ -4,9 +4,11 @@ A manual smoketest checklist to ensure features are working:
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
### Default
|
### Default
|
||||||
- [ ] Whichkey should have accurate keybindings
|
- [ ] Whichkey groups should have accurate keybindings
|
||||||
|
- c -> LSP: [C]ode
|
||||||
- g -> [G]it
|
- g -> [G]it
|
||||||
- n -> [N]otepad
|
- n -> [N]otepad
|
||||||
|
- r -> [R]e[N]ame
|
||||||
- s -> [S]earch
|
- s -> [S]earch
|
||||||
- t -> [T]oggle
|
- t -> [T]oggle
|
||||||
|
|
||||||
|
|
|
||||||
25
init.lua
25
init.lua
|
|
@ -375,10 +375,11 @@ do
|
||||||
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
|
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
|
||||||
{ '<leader>t', group = '[T]oggle' },
|
{ '<leader>t', group = '[T]oggle' },
|
||||||
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, -- Enable gitsigns recommended keymaps first
|
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, -- Enable gitsigns recommended keymaps first
|
||||||
-- TODO: LSP actions (anything with `gr`) should be with the leader key
|
|
||||||
{ 'gr', group = 'LSP Actions', mode = { 'n' } },
|
|
||||||
{ '<leader>g', group = '[G]it' },
|
{ '<leader>g', group = '[G]it' },
|
||||||
{ '<leader>n', group = '[N]otepad' },
|
{ '<leader>n', group = '[N]otepad' },
|
||||||
|
{ '<leader>r', group = '[R]e[N]ame', mode = { 'n' } },
|
||||||
|
{ '<leader>c', group = 'LSP: [C]ode', mode = { 'n' } },
|
||||||
|
{ '<leader>cg', group = 'LSP: [G]oto', mode = { 'n' } },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -543,29 +544,29 @@ do
|
||||||
local buf = event.buf
|
local buf = event.buf
|
||||||
|
|
||||||
-- Find references for the word under your cursor.
|
-- Find references for the word under your cursor.
|
||||||
vim.keymap.set('n', 'grr', builtin.lsp_references, { buffer = buf, desc = '[G]oto [R]eferences' })
|
vim.keymap.set('n', '<leader>cgr', builtin.lsp_references, { buffer = buf, desc = '[G]oto [R]eferences' })
|
||||||
|
|
||||||
-- Jump to the implementation of the word under your cursor.
|
-- Jump to the implementation of the word under your cursor.
|
||||||
-- Useful when your language has ways of declaring types without an actual implementation.
|
-- Useful when your language has ways of declaring types without an actual implementation.
|
||||||
vim.keymap.set('n', 'gri', builtin.lsp_implementations, { buffer = buf, desc = '[G]oto [I]mplementation' })
|
vim.keymap.set('n', '<leader>cgi', builtin.lsp_implementations, { buffer = buf, desc = '[G]oto [I]mplementation' })
|
||||||
|
|
||||||
-- Jump to the definition of the word under your cursor.
|
-- Jump to the definition of the word under your cursor.
|
||||||
-- This is where a variable was first declared, or where a function is defined, etc.
|
-- This is where a variable was first declared, or where a function is defined, etc.
|
||||||
-- To jump back, press <C-t>.
|
-- To jump back, press <C-t>.
|
||||||
vim.keymap.set('n', 'grd', builtin.lsp_definitions, { buffer = buf, desc = '[G]oto [D]efinition' })
|
vim.keymap.set('n', '<leader>cgd', builtin.lsp_definitions, { buffer = buf, desc = '[G]oto [D]efinition' })
|
||||||
|
|
||||||
-- Fuzzy find all the symbols in your current document.
|
-- Fuzzy find all the symbols in your current document.
|
||||||
-- Symbols are things like variables, functions, types, etc.
|
-- Symbols are things like variables, functions, types, etc.
|
||||||
vim.keymap.set('n', 'gO', builtin.lsp_document_symbols, { buffer = buf, desc = 'Open Document Symbols' })
|
vim.keymap.set('n', '<leader>cgO', builtin.lsp_document_symbols, { buffer = buf, desc = 'Open Document Symbols' })
|
||||||
|
|
||||||
-- Fuzzy find all the symbols in your current workspace.
|
-- Fuzzy find all the symbols in your current workspace.
|
||||||
-- Similar to document symbols, except searches over your entire project.
|
-- Similar to document symbols, except searches over your entire project.
|
||||||
vim.keymap.set('n', 'gW', builtin.lsp_dynamic_workspace_symbols, { buffer = buf, desc = 'Open Workspace Symbols' })
|
vim.keymap.set('n', '<leader>cgW', builtin.lsp_dynamic_workspace_symbols, { buffer = buf, desc = 'Open Workspace Symbols' })
|
||||||
|
|
||||||
-- Jump to the type of the word under your cursor.
|
-- Jump to the type of the word under your cursor.
|
||||||
-- Useful when you're not sure what type a variable is and you want to see
|
-- Useful when you're not sure what type a variable is and you want to see
|
||||||
-- the definition of its *type*, not where it was *defined*.
|
-- the definition of its *type*, not where it was *defined*.
|
||||||
vim.keymap.set('n', 'grt', builtin.lsp_type_definitions, { buffer = buf, desc = '[G]oto [T]ype Definition' })
|
vim.keymap.set('n', '<leader>cgt', builtin.lsp_type_definitions, { buffer = buf, desc = '[G]oto [T]ype Definition' })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -650,15 +651,15 @@ do
|
||||||
|
|
||||||
-- Rename the variable under your cursor.
|
-- Rename the variable under your cursor.
|
||||||
-- Most Language Servers support renaming across files, etc.
|
-- Most Language Servers support renaming across files, etc.
|
||||||
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
|
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
|
|
||||||
-- Execute a code action, usually your cursor needs to be on top of an error
|
-- 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.
|
-- or a suggestion from your LSP for this to activate.
|
||||||
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
|
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
|
||||||
|
|
||||||
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
||||||
-- For example, in C this would take you to the header.
|
-- For example, in C this would take you to the header.
|
||||||
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
map('<leader>cgD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||||
|
|
||||||
-- The following two autocommands are used to highlight references of the
|
-- The following two autocommands are used to highlight references of the
|
||||||
-- word under your cursor when your cursor rests there for a little while.
|
-- word under your cursor when your cursor rests there for a little while.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue