feat(keymap): reorganize <leader>g prefix, add LSP goto keymaps
This commit is contained in:
parent
953e5b7d5c
commit
99d232e902
39
init.lua
39
init.lua
|
|
@ -398,7 +398,8 @@ require('lazy').setup({
|
||||||
{ '<leader>c', group = '[C]Make' },
|
{ '<leader>c', group = '[C]Make' },
|
||||||
{ '<leader>d', group = '[D]iagnostics' },
|
{ '<leader>d', group = '[D]iagnostics' },
|
||||||
{ '<leader>e', group = '[E]xplorer' },
|
{ '<leader>e', group = '[E]xplorer' },
|
||||||
{ '<leader>g', group = '[G]it' },
|
{ '<leader>g', group = '[G]oto' },
|
||||||
|
{ '<leader>G', group = '[G]it' },
|
||||||
{ '<leader>m', group = '[M]arkdown' },
|
{ '<leader>m', group = '[M]arkdown' },
|
||||||
{ '<leader>n', group = '[N]eotest' },
|
{ '<leader>n', group = '[N]eotest' },
|
||||||
{ '<leader>o', group = '[O]pencode' },
|
{ '<leader>o', group = '[O]pencode' },
|
||||||
|
|
@ -606,19 +607,23 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- Find references for the word under your cursor.
|
-- Find references for the word under your cursor.
|
||||||
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||||
|
map('<leader>gr', require('telescope.builtin').lsp_references, '[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.
|
||||||
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||||
|
map('<leader>gi', require('telescope.builtin').lsp_implementations, '[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>.
|
||||||
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||||
|
map('<leader>gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||||
|
|
||||||
-- 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('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||||
|
map('<leader>gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||||
|
|
||||||
-- 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.
|
||||||
|
|
@ -632,6 +637,7 @@ require('lazy').setup({
|
||||||
-- 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*.
|
||||||
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
|
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
|
||||||
|
map('<leader>gt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
|
||||||
|
|
||||||
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
|
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
|
||||||
---@param client vim.lsp.Client
|
---@param client vim.lsp.Client
|
||||||
|
|
@ -1064,6 +1070,13 @@ require('lazy').setup({
|
||||||
-- - sr)' - [S]urround [R]eplace [)] [']
|
-- - sr)' - [S]urround [R]eplace [)] [']
|
||||||
require('mini.surround').setup()
|
require('mini.surround').setup()
|
||||||
|
|
||||||
|
-- Delete buffers while preserving window layout.
|
||||||
|
local bufremove = require 'mini.bufremove'
|
||||||
|
bufremove.setup()
|
||||||
|
vim.keymap.set('n', '<leader>bd', function()
|
||||||
|
bufremove.delete(0, false)
|
||||||
|
end, { desc = '[B]uffer [D]elete' })
|
||||||
|
|
||||||
-- Simple and easy statusline.
|
-- Simple and easy statusline.
|
||||||
-- You could remove this setup call if you don't like it,
|
-- You could remove this setup call if you don't like it,
|
||||||
-- and try some other statusline plugin
|
-- and try some other statusline plugin
|
||||||
|
|
@ -1085,20 +1098,26 @@ require('lazy').setup({
|
||||||
},
|
},
|
||||||
{ -- Highlight, edit, and navigate code
|
{ -- Highlight, edit, and navigate code
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
branch = 'main',
|
||||||
lazy = false,
|
lazy = false,
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
opts = {
|
config = function()
|
||||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
|
|
||||||
auto_install = true,
|
|
||||||
},
|
|
||||||
config = function(_, opts)
|
|
||||||
local treesitter = require 'nvim-treesitter'
|
local treesitter = require 'nvim-treesitter'
|
||||||
treesitter.setup()
|
treesitter.setup()
|
||||||
|
require('nvim-treesitter.install').ensure_installed {
|
||||||
if opts.auto_install and opts.ensure_installed and #opts.ensure_installed > 0 then
|
'bash',
|
||||||
treesitter.install(opts.ensure_installed)
|
'c',
|
||||||
end
|
'diff',
|
||||||
|
'html',
|
||||||
|
'lua',
|
||||||
|
'luadoc',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
|
'query',
|
||||||
|
'vim',
|
||||||
|
'vimdoc',
|
||||||
|
}
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
group = vim.api.nvim_create_augroup('kickstart-treesitter', { clear = true }),
|
group = vim.api.nvim_create_augroup('kickstart-treesitter', { clear = true }),
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ return {
|
||||||
'DiffviewRefresh',
|
'DiffviewRefresh',
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{ '<leader>gd', '<cmd>DiffviewOpen<CR>', desc = '[G]it [D]iff view' },
|
{ '<leader>Gd', '<cmd>DiffviewOpen<CR>', desc = '[G]it [D]iff view' },
|
||||||
{ '<leader>gD', '<cmd>DiffviewClose<CR>', desc = '[G]it [D]iff close' },
|
{ '<leader>GD', '<cmd>DiffviewClose<CR>', desc = '[G]it [D]iff close' },
|
||||||
{ '<leader>gf', '<cmd>DiffviewFileHistory %<CR>', desc = '[G]it [F]ile history' },
|
{ '<leader>Gf', '<cmd>DiffviewFileHistory %<CR>', desc = '[G]it [F]ile history' },
|
||||||
{ '<leader>gF', '<cmd>DiffviewFileHistory<CR>', desc = '[G]it [F]ull history' },
|
{ '<leader>GF', '<cmd>DiffviewFileHistory<CR>', desc = '[G]it [F]ull history' },
|
||||||
},
|
},
|
||||||
opts = {},
|
opts = {},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,6 @@ return {
|
||||||
},
|
},
|
||||||
cmd = 'Neogit',
|
cmd = 'Neogit',
|
||||||
keys = {
|
keys = {
|
||||||
{ '<leader>gg', '<cmd>Neogit<cr>', desc = 'Show Neogit UI' },
|
{ '<leader>Gg', '<cmd>Neogit<cr>', desc = 'Show Neogit UI' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue