nvim: document keymaps
This commit is contained in:
parent
9afc3d3316
commit
8b10686865
@ -35,7 +35,7 @@ require('Comment').setup({
|
||||
}
|
||||
end
|
||||
})
|
||||
map('i', '<M-c>', '<Leader>cA')
|
||||
map('i', '<M-c>', '<Leader>cA', 'Add comment at eol')
|
||||
|
||||
local neogit = require('neogit')
|
||||
neogit.setup {
|
||||
@ -45,8 +45,7 @@ neogit.setup {
|
||||
diffview = true
|
||||
}
|
||||
}
|
||||
|
||||
map('n', '<Leader>g', neogit.open)
|
||||
map('n', '<Leader>gg', neogit.open, 'Open Neogit')
|
||||
|
||||
-- start git commits in insert mode
|
||||
vim.api.nvim_create_augroup('config_coding', { clear = true })
|
||||
|
@ -6,7 +6,7 @@ vim.g.maplocalleader = ' ' -- <LocalLeader> (2 spaces)
|
||||
local format = string.format
|
||||
|
||||
-- buffers
|
||||
map('n', '<Leader>b', ':buffers<CR>:buffer<Space>')
|
||||
map('n', '<Leader>b', ':buffers<CR>:buffer<Space>', 'Show open buffers')
|
||||
for key, cmd in pairs({ Left = 'bprevious', Right = 'bnext' }) do
|
||||
map('n', format('<M-%s>', key), format(':%s<cr>', cmd))
|
||||
map('i', format('<M-%s>', key), format('<esc>:%s<cr>', cmd))
|
||||
@ -55,8 +55,8 @@ map({ 'n', 'i' }, '<C-S-Del>',
|
||||
)
|
||||
|
||||
-- system clipboard
|
||||
map('v', '<Leader>y', '"+y')
|
||||
map('n', '<Leader>p', '"+p')
|
||||
map('v', '<Leader>y', '"+y', 'Yank to system clipboard')
|
||||
map('n', '<Leader>p', '"+p', 'Paste from system clipboard')
|
||||
|
||||
-- toggle between beginning of line and beginning of text
|
||||
map({ 'n', 'i', 'v' }, '<Home>',
|
||||
@ -79,8 +79,8 @@ for _, key in ipairs({ 'Left', 'Up', 'Down', 'Right' }) do
|
||||
map({ 'v' }, format('<S-%s>', key), format('<%s>', key))
|
||||
end
|
||||
|
||||
map('n', '<F9>', ':Lexplore 20<cr>') -- file explorer, 20% wide
|
||||
map('i', '<F9>', '<Esc>:Lexplore 20<cr>')
|
||||
map('n', '<F9>', ':Lexplore 20<cr>', 'Open file explorer')
|
||||
map('i', '<F9>', '<Esc>:Lexplore 20<cr>', 'Open file explorer')
|
||||
map('n', '<M-.>', '<C-]>') -- follow symbol
|
||||
map('n', '<M-,>', '<C-T>') -- go back to previous pos
|
||||
map('v', '<Leader>f', 'gq') -- format text
|
||||
map('v', '<Leader>f', 'gq', 'Reformat text')
|
||||
|
@ -5,28 +5,26 @@ local map = require('my.functions').map
|
||||
|
||||
-- only do this after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
local function map(mode, shortcut, command) -- overwrite function in keymaps
|
||||
vim.keymap.set(mode, shortcut, command, {
|
||||
noremap = true, silent = true, buffer=bufnr })
|
||||
end
|
||||
|
||||
map('n', '<f5>', vim.diagnostic.goto_prev)
|
||||
map('n', '<f6>', vim.diagnostic.goto_next)
|
||||
map('n', 'gD', vim.lsp.buf.declaration)
|
||||
map('n', 'gd', vim.lsp.buf.definition)
|
||||
map('n', '<M-.>', vim.lsp.buf.definition)
|
||||
map('n', 'gi', vim.lsp.buf.implementation)
|
||||
map('n', 'gr', vim.lsp.buf.references)
|
||||
map('n', 'K', vim.lsp.buf.hover)
|
||||
map('n', '<C-k>', vim.lsp.buf.signature_help)
|
||||
map('n', '<Leader>lwa', vim.lsp.buf.add_workspace_folder)
|
||||
map('n', '<Leader>lwr', vim.lsp.buf.remove_workspace_folder)
|
||||
map('n', '<f5>', vim.diagnostic.goto_prev, nil, bufnr)
|
||||
map('n', '<f6>', vim.diagnostic.goto_next, nil, bufnr)
|
||||
map('n', 'gD', vim.lsp.buf.declaration, 'Go to declaration', bufnr)
|
||||
map('n', 'gd', vim.lsp.buf.definition, 'Go to definition', bufnr)
|
||||
map('n', '<M-.>', vim.lsp.buf.definition, 'Go to definition', bufnr)
|
||||
map('n', 'gi', vim.lsp.buf.implementation, 'Go to implementation',
|
||||
bufnr)
|
||||
map('n', 'gr', vim.lsp.buf.references, 'Show references', bufnr)
|
||||
map('n', 'K', vim.lsp.buf.hover, 'Hover', bufnr)
|
||||
map('n', '<C-k>', vim.lsp.buf.signature_help, 'Show signature', bufnr)
|
||||
map('n', '<Leader>lwa', vim.lsp.buf.add_workspace_folder,
|
||||
'Add workspace folder', bufnr)
|
||||
map('n', '<Leader>lwr', vim.lsp.buf.remove_workspace_folder,
|
||||
'Remove workspace folder', bufnr)
|
||||
map('n', '<Leader>lwl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end)
|
||||
map('n', '<Leader>lr', vim.lsp.buf.rename)
|
||||
map('n', '<Leader>la', vim.lsp.buf.code_action)
|
||||
map('n', '<Leader>lf', vim.lsp.buf.formatting)
|
||||
end, 'List workspace folders', bufnr)
|
||||
map('n', '<Leader>lr', vim.lsp.buf.rename, 'Rename symbol', bufnr)
|
||||
map('n', '<Leader>la', vim.lsp.buf.code_action, 'Code action', bufnr)
|
||||
map('n', '<Leader>lf', vim.lsp.buf.formatting, 'Format buffer', bufnr)
|
||||
|
||||
-- highlight symbol under cursor
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
|
@ -27,13 +27,13 @@ require('telescope').setup {
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
local my = require('my.functions')
|
||||
map('n', '<Leader>tb', builtin.buffers)
|
||||
map('n', '<Leader>tb', builtin.buffers, 'Open buffers')
|
||||
map('n', '<Leader>tf', function()
|
||||
builtin.find_files({ cwd = my.get_project_root() })
|
||||
end)
|
||||
map('n', '<Leader>to', builtin.oldfiles)
|
||||
end, 'Files')
|
||||
map('n', '<Leader>to', builtin.oldfiles, 'Recently opened files')
|
||||
map('n', '<Leader>tg', function()
|
||||
builtin.live_grep({ cwd = my.get_project_root() })
|
||||
end)
|
||||
map('n', '<Leader>tm', builtin.man_pages)
|
||||
map('n', '<Leader>tr', builtin.registers)
|
||||
end, 'Live-grep')
|
||||
map('n', '<Leader>tm', builtin.man_pages, 'Man pages')
|
||||
map('n', '<Leader>tr', builtin.registers, 'Register')
|
||||
|
Loading…
x
Reference in New Issue
Block a user