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

@ -40,19 +40,19 @@ local function wrap_down()
return 'j' return 'j'
end end
map('n', 'k', wrap_up, {expr = true}) map('n', 'k', wrap_up, { expr = true })
map('n', 'j', wrap_down, {expr = true}) map('n', 'j', wrap_down, { expr = true })
-- move around between matching brackets with tab -- move around between matching brackets with tab
map('n', '<Tab>', '%') map('n', '<Tab>', '%')
-- when in insertion mode, C-u uppercases the current word, C-l lowercases it, -- when in insertion mode, C-u uppercases the current word, C-l lowercases it,
map('i', '<C-u>', '<esc>gUiw`]a') 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>')
@ -82,75 +82,94 @@ vim.g.maplocalleader = ","
-- FIXME does this work still (and is it necessary)? -- FIXME does this work still (and is it necessary)?
if vim.g.maplocalleader == ',' then if vim.g.maplocalleader == ',' then
map('', ',,', ',') map('', ',,', ',')
vim.keymap.del('', ',,', {silent=true}) vim.keymap.del('', ',,', { silent = true })
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
@ -158,17 +177,20 @@ map('n', '<localleader>f', ':FormatLock<cr>')
map('n', '<localleader>F', ':FormatWriteLock<cr>') map('n', '<localleader>F', ':FormatWriteLock<cr>')
-- Enter distraction free prose mode with F11 -- Enter distraction free prose mode with F11
map('n', '<F11>', ':ZenMode<cr>', {silent=true}) 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,22 +200,26 @@ 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 })
map("n", "<C-x>", require("dial.map").dec_normal(), {noremap = true}) map("n", "<C-x>", require("dial.map").dec_normal(), { noremap = true })
map("v", "<C-a>", require("dial.map").inc_visual(), {noremap = true}) map("v", "<C-a>", require("dial.map").inc_visual(), { noremap = true })
map("v", "<C-x>", require("dial.map").dec_visual(), {noremap = true}) map("v", "<C-x>", require("dial.map").dec_visual(), { noremap = true })
map("v", "g<C-a>",require("dial.map").inc_gvisual(), {noremap = true}) map("v", "g<C-a>", require("dial.map").inc_gvisual(), { noremap = true })
map("v", "g<C-x>",require("dial.map").dec_gvisual(), {noremap = true}) map("v", "g<C-x>", require("dial.map").dec_gvisual(), { noremap = true })
-- PLUGIN: zettelkasten.nvim -- PLUGIN: zettelkasten.nvim
map('n', '<cr>', [[:silent lua require 'zettelkasten'.link_follow()<cr>]]) map('n', '<cr>', [[:silent lua require 'zettelkasten'.link_follow()<cr>]])
@ -206,22 +232,27 @@ 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>',
map('x', '<localleader>m', ':<C-u>MagmaEvaluateVisual<cr>', {silent=true}) { silent = true, desc = 'Evaluate current quarto cell' })
map('n', '<localleader>m', "nvim_exec('MagmaEvaluateOperator', v:true)", {expr=true, silent=true}) map('x', '<localleader>m', ':<C-u>MagmaEvaluateVisual<cr>', { silent = true })
map('n', '<localleader>mr', ':MagmaReevaluateCell<cr>', {silent=true}) map('n', '<localleader>m', "nvim_exec('MagmaEvaluateOperator', v:true)",
map('n', '<localleader>ma', ':MagmaShowOutput<cr>', {silent=true}) { expr = true, silent = true })
map('n', '<localleader>mq', ':noautocmd :MagmaEnterOutput<cr>', {silent=true}) map('n', '<localleader>mr', ':MagmaReevaluateCell<cr>', { silent = true })
map('n', '<localleader>md', ':MagmaDelete<cr>', {silent=true}) map('n', '<localleader>ma', ':MagmaShowOutput<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>ms', ':MagmaInterrupt<cr>') map('n', '<localleader>ms', ':MagmaInterrupt<cr>')
map('n', '<localleader>mI', ':MagmaInit ') map('n', '<localleader>mI', ':MagmaInit ')
map('n', '<localleader>mD', ':MagmaDeinit<cr>') 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' })