nvim: Add mapping description for which-key

This commit is contained in:
Marty Oehme 2023-02-10 11:47:09 +01:00
parent e8d2183264
commit 7965036eed
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -51,8 +51,8 @@ map('i', '<C-u>', '<esc>gUiw`]a')
map('i', '<C-y>', '<esc>guiw`]a') map('i', '<C-y>', '<esc>guiw`]a')
-- yank current filename/filepath to f buffer -- yank current filename/filepath to f buffer
map('n', 'yp', ':let @p = expand("%")<Cr>') map('n', 'yp', ':let @p = expand("%")<Cr>', { desc = 'yank filename' })
map('n', 'yP', ':let @p = expand("%:p")<Cr>') map('n', 'yP', ':let @p = expand("%:p")<Cr>', { desc = 'yank filepath' })
-- repeat the last substitute command with all its flags preserved -- repeat the last substitute command with all its flags preserved
map('n', '&', ':&&<cr>') map('n', '&', ':&&<cr>')
@ -86,71 +86,90 @@ if vim.g.maplocalleader == ',' then
end end
-- remove search highlights by pressing space+/ -- remove search highlights by pressing space+/
map('n', '<leader>/', ':noh<cr>') map('n', '<leader>/', ':noh<cr>', { desc = 'remove highlights' })
-- split buffers vertically/horizontally with the leader \ or - (mirrors my -- split buffers vertically/horizontally with the leader \ or - (mirrors my
-- tmux setup) -- tmux setup)
map('n', '<leader>-', ':sp<cr>') map('n', '<leader>-', ':sp<cr>', { desc = 'open horiz split' })
map('n', '<leader>\\', ':vsp<cr>') map('n', '<leader>\\', ':vsp<cr>', { desc = 'open vert split' })
-- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) -- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it)
map('n', '<leader>t', ':vsp .<cr>') map('n', '<leader>t', ':vsp | Vifm<cr>', { desc = 'open buffer' })
-- open actual new tab with leader-T -- open actual new tab with leader-T
map('n', '<leader>T', ':tabedit .<cr>') map('n', '<leader>T', ':tabedit | Vifm<cr>', { desc = 'open tab' })
-- select the whole buffer with <leader>-a -- select the whole buffer with <leader>-a
map('n', '<leader>a', 'ggVG') map('n', '<leader>a', 'ggVG', { desc = 'select all' })
-- PLUGIN: Navigator.nvim -- PLUGIN: Navigator.nvim
map('n', '<c-w>h', '<CMD>lua require("Navigator").left()<cr>', { silent = true }) map('n', '<c-w>h', '<CMD>lua require("Navigator").left()<cr>', { silent = true })
map('n', '<c-w>k', '<CMD>lua require("Navigator").up()<cr>', { silent = true }) map('n', '<c-w>k', '<CMD>lua require("Navigator").up()<cr>', { silent = true })
map('n', '<c-w>l', '<CMD>lua require("Navigator").right()<cr>', { silent = true }) map('n', '<c-w>l', '<CMD>lua require("Navigator").right()<cr>', { silent = true })
map('n', '<c-w>j', '<CMD>lua require("Navigator").down()<cr>', { silent = true }) map('n', '<c-w>j', '<CMD>lua require("Navigator").down()<cr>', { silent = true })
map('n', '<c-w>p', '<CMD>lua require("Navigator").previous()<cr>', {silent = true}) map('n', '<c-w>p', '<CMD>lua require("Navigator").previous()<cr>',
{ silent = true })
-- PLUGIN: Vifm.vim -- PLUGIN: Vifm.vim
-- open/close file tree with leader-e -- open/close file tree with leader-e
map('n', '<leader>e', ':Vifm<cr>') map('n', '<leader>e', ':Vifm<cr>', { desc = 'browse files' })
-- open current file tree with current file directory -- open current file tree with current file directory
map('n', '<leader>E', ':Vifm getcwd()<cr>') map('n', '<leader>E', ':Vifm getcwd()<cr>', { desc = 'browse project' })
-- PLUGIN: Telescope GLOBAL FUZZY FINDING -- PLUGIN: Telescope GLOBAL FUZZY FINDING
-- buffers and files in current workdir -- buffers and files in current workdir
map('n', '<leader>s',":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>") map('n', '<leader>s',
":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>",
{ desc = 'list buffers' })
-- most recently used / MRU, bound to S since it is essentially a larger -- most recently used / MRU, bound to S since it is essentially a larger
-- go-back intention than just buffers -- go-back intention than just buffers
map('n', '<leader>S',":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>") map('n', '<leader>S',
":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>",
{ desc = 'list old files' })
-- fuzzy find files in cwd -- fuzzy find files in cwd
map('n', '<leader>f',":lua require 'telescope.builtin'.find_files()<cr>") map('n', '<leader>f', ":lua require 'telescope.builtin'.find_files()<cr>",
{ desc = 'find files' })
-- fuzzy find hidden files in cwd -- fuzzy find hidden files in cwd
map('n', '<leader><c-f>',":lua require 'telescope.builtin'.find_files({hidden=true})<cr>") map('n', '<leader><c-f>',
":lua require 'telescope.builtin'.find_files({hidden=true})<cr>",
{ desc = 'find hidden files' })
-- general full-text search in cwd with rg -- general full-text search in cwd with rg
map('n', '<leader>F',":lua require 'telescope.builtin'.live_grep()<cr>") map('n', '<leader>F', ":lua require 'telescope.builtin'.live_grep()<cr>",
{ desc = 'grep search' })
-- git status -- git status
map('n', '<leader>gs',":lua require 'telescope.builtin'.git_status()<cr>") map('n', '<leader>gs', ":lua require 'telescope.builtin'.git_status()<cr>",
{ desc = 'git status' })
-- git buffercommits -- git buffercommits
map('n', '<leader>gb',":lua require 'telescope.builtin'.git_bcommits()<cr>") map('n', '<leader>gb', ":lua require 'telescope.builtin'.git_bcommits()<cr>",
{ desc = 'git buffer commits' })
-- git commitlog -- git commitlog
map('n', '<leader>gl',":lua require 'telescope.builtin'.git_commits()<cr>") map('n', '<leader>gl', ":lua require 'telescope.builtin'.git_commits()<cr>",
{ desc = 'git commit log' })
-- helptags -- helptags
map('n', '<leader><F1>',":lua require 'telescope.builtin'.help_tags()<cr>") map('n', '<leader><F1>', ":lua require 'telescope.builtin'.help_tags()<cr>",
{ desc = 'help tags' })
-- manpages -- manpages
map('n', '<leader><F2>',":lua require 'telescope.builtin'.man_pages()<cr>") map('n', '<leader><F2>', ":lua require 'telescope.builtin'.man_pages()<cr>",
{ desc = 'man pages' })
-- colorschemes -- colorschemes
map('n', '<leader><F8>',":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>") map('n', '<leader><F8>',
":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>",
{ desc = 'colorschemes' })
-- spell suggestions -- spell suggestions
map('n', 'z=',":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>") map('n', 'z=',
":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>")
-- Format current Paragraph (esp useful in prose writing) -- Format current Paragraph (esp useful in prose writing)
map('n', '<localleader>q', 'gqap', {silent=true}) map('n', '<localleader>q', 'gqap',
map('x', '<localleader>q', 'gq', {silent=true}) { silent = true, desc = 'Format current paragraph' })
map('n', '<localleader>Q', 'vapJgqap', {silent=true}) map('x', '<localleader>q', 'gq', { silent = true, desc = 'Format {motion}' })
map('n', '<localleader>Q', 'vapJgqap',
{ silent = true, desc = 'Unformat then format paragraph' })
map('n', '<localleader>mp', '<Plug>MarkdownPreviewToggle') map('n', '<localleader>mp', '<Plug>MarkdownPreviewToggle',
{ desc = 'Toggle md preview' })
-- FORMAT code with -- FORMAT code with
-- PLUGIN: formatter.nvim -- PLUGIN: formatter.nvim
@ -163,12 +182,15 @@ map('n', '<F11>', ':ZenMode<cr>', {silent=true})
-- SPELL CHECKING -- SPELL CHECKING
-- Move to the prev/next spelling error with [S ]S -- Move to the prev/next spelling error with [S ]S
-- Move to the prev/next spelling error or suggestion with [s ]s -- Move to the prev/next spelling error or suggestion with [s ]s
map('n', '<localleader>ZZ', ':setlocal spell! spelllang=en_us,de_de<cr>') map('n', '<localleader>ZZ', ':setlocal spell! spelllang=en_us,de_de<cr>',
map('n', '<localleader>ZE', ':setlocal spell! spelllang=en_us<cr>') { desc = 'Toggle spellcheck' })
map('n', '<localleader>ZG', ':setlocal spell! spelllang=de_de<cr>') map('n', '<localleader>ZE', ':setlocal spell! spelllang=en_us<cr>',
{ desc = 'Toggle EN spellcheck' })
map('n', '<localleader>ZG', ':setlocal spell! spelllang=de_de<cr>',
{ desc = 'Toggle DE spellcheck' })
-- undo last spelling mistake from insert and normal mode -- undo last spelling mistake from insert and normal mode
map('i', '<c-s>', '<C-G>u<Esc>[s1z=`]a<C-G>u') map('i', '<c-s>', '<C-G>u<Esc>[s1z=`]a<C-G>u')
map('n', '<localleader>s', 'ms[s1z=`s') map('n', '<localleader>s', 'ms[s1z=`s', { desc = 'Fix last spell error' })
-- PLUGIN: easy-align -- PLUGIN: easy-align
-- Start interactive EasyAlign in visual mode (e.g. vipga) -- Start interactive EasyAlign in visual mode (e.g. vipga)
@ -178,14 +200,18 @@ map('n', 'ga', '<Plug>(EasyAlign)')
-- PLUGIN: vnsip -- PLUGIN: vnsip
-- jump around in snippets -- jump around in snippets
map('i', '<Tab>', [[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']], {expr=true}) map('i', '<Tab>', [[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']],
map('i', '<S-Tab>', [[vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>']], {expr=true}) { expr = true })
map('i', '<S-Tab>',
[[vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>']],
{ expr = true })
-- PLUGIN: symbols-outline.nvim -- PLUGIN: symbols-outline.nvim
map('n', '<leader>o', '<cmd>SymbolsOutline<cr>', { silent = true }) map('n', '<leader>o', '<cmd>SymbolsOutline<cr>', { silent = true })
-- trim trailing whitespaces with mini.nvim trailspace -- trim trailing whitespaces with mini.nvim trailspace
map("n", "<localleader>w", function() require("mini.trailspace").trim() end, {noremap = true}) map("n", "<localleader>w", function() require("mini.trailspace").trim() end,
{ noremap = true })
-- PLUGIN: dial-increment -- PLUGIN: dial-increment
map("n", "<C-a>", require("dial.map").inc_normal(), { noremap = true }) map("n", "<C-a>", require("dial.map").inc_normal(), { noremap = true })
@ -207,12 +233,15 @@ map('n', '<leader>G', ':Lazygit<cr>')
-- PLUGIN: magma-nvim -- PLUGIN: magma-nvim
-- Operate jupyter notebooks from within vim -- Operate jupyter notebooks from within vim
map('n', '<localleader>mm', ':MagmaEvaluateLine<cr>', { silent = true }) map('n', '<localleader>mm', ':MagmaEvaluateLine<cr>', { silent = true })
map('n', '<localleader>M', '?^```{<cr>jV/```<cr>k:<C-u>MagmaEvaluateVisual<cr>', {silent=true}) map('n', '<localleader>M', '?^```{<cr>jV/```<cr>k:<C-u>MagmaEvaluateVisual<cr>',
{ silent = true, desc = 'Evaluate current quarto cell' })
map('x', '<localleader>m', ':<C-u>MagmaEvaluateVisual<cr>', { silent = true }) map('x', '<localleader>m', ':<C-u>MagmaEvaluateVisual<cr>', { silent = true })
map('n', '<localleader>m', "nvim_exec('MagmaEvaluateOperator', v:true)", {expr=true, silent=true}) map('n', '<localleader>m', "nvim_exec('MagmaEvaluateOperator', v:true)",
{ expr = true, silent = true })
map('n', '<localleader>mr', ':MagmaReevaluateCell<cr>', { silent = true }) map('n', '<localleader>mr', ':MagmaReevaluateCell<cr>', { silent = true })
map('n', '<localleader>ma', ':MagmaShowOutput<cr>', { silent = true }) map('n', '<localleader>ma', ':MagmaShowOutput<cr>', { silent = true })
map('n', '<localleader>mq', ':noautocmd :MagmaEnterOutput<cr>', {silent=true}) map('n', '<localleader>mq', ':noautocmd :MagmaEnterOutput<cr>',
{ silent = true, desc = 'MagmaEnterOutput' })
map('n', '<localleader>md', ':MagmaDelete<cr>', { silent = true }) map('n', '<localleader>md', ':MagmaDelete<cr>', { silent = true })
map('n', '<localleader>ms', ':MagmaInterrupt<cr>') map('n', '<localleader>ms', ':MagmaInterrupt<cr>')
map('n', '<localleader>mI', ':MagmaInit ') map('n', '<localleader>mI', ':MagmaInit ')
@ -220,8 +249,10 @@ map('n', '<localleader>mD', ':MagmaDeinit<cr>')
map('n', '<localleader>mR', ':MagmaRestart<cr>') map('n', '<localleader>mR', ':MagmaRestart<cr>')
-- jump to beginning of previous/ next cell code -- jump to beginning of previous/ next cell code
map('n', ']c', '/^```{<cr>}:nohl<cr>') map('n', ']c', '/^```{<cr>}:nohl<cr>', { desc = 'Next quarto cell' })
map('n', '[c', '?^```<cr>n}:nohl<cr>') map('n', '[c', '?^```<cr>n}:nohl<cr>', { desc = 'Previous quarto cell' })
-- insert cell header above/below -- insert cell header above/below
map('n', '<localleader>mo', 'o```{python}<cr><cr>```<esc>k') map('n', '<localleader>mo', 'o```{python}<cr><cr>```<esc>k',
map('n', '<localleader>mO', 'O```{python}<cr><cr>```<esc>k') { desc = 'Insert quarto cell below' })
map('n', '<localleader>mO', 'O```{python}<cr><cr>```<esc>k',
{ desc = 'Insert quarto cell above' })