From 7965036eed43084ec210c0ffcad3d6b6779c8a04 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 10 Feb 2023 11:47:09 +0100 Subject: [PATCH] nvim: Add mapping description for which-key --- nvim/.config/nvim/lua/maps.lua | 159 ++++++++++++++++++++------------- 1 file changed, 95 insertions(+), 64 deletions(-) diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua index f9c8fe5..bb41f83 100644 --- a/nvim/.config/nvim/lua/maps.lua +++ b/nvim/.config/nvim/lua/maps.lua @@ -40,19 +40,19 @@ local function wrap_down() return 'j' end -map('n', 'k', wrap_up, {expr = true}) -map('n', 'j', wrap_down, {expr = true}) +map('n', 'k', wrap_up, { expr = true }) +map('n', 'j', wrap_down, { expr = true }) -- move around between matching brackets with tab map('n', '', '%') -- when in insertion mode, C-u uppercases the current word, C-l lowercases it, -map('i', '', 'gUiw`]a') -map('i', '', 'guiw`]a') +map('i', '', 'gUiw`]a') +map('i', '', 'guiw`]a') -- yank current filename/filepath to f buffer -map('n', 'yp', ':let @p = expand("%")') -map('n', 'yP', ':let @p = expand("%:p")') +map('n', 'yp', ':let @p = expand("%")', { desc = 'yank filename' }) +map('n', 'yP', ':let @p = expand("%:p")', { desc = 'yank filepath' }) -- repeat the last substitute command with all its flags preserved map('n', '&', ':&&') @@ -82,75 +82,94 @@ vim.g.maplocalleader = "," -- FIXME does this work still (and is it necessary)? if vim.g.maplocalleader == ',' then map('', ',,', ',') - vim.keymap.del('', ',,', {silent=true}) + vim.keymap.del('', ',,', { silent = true }) end -- remove search highlights by pressing space+/ -map('n', '/', ':noh') +map('n', '/', ':noh', { desc = 'remove highlights' }) -- split buffers vertically/horizontally with the leader \ or - (mirrors my -- tmux setup) -map('n', '-', ':sp') -map('n', '\\', ':vsp') +map('n', '-', ':sp', { desc = 'open horiz split' }) +map('n', '\\', ':vsp', { desc = 'open vert split' }) -- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) -map('n', 't', ':vsp .') +map('n', 't', ':vsp | Vifm', { desc = 'open buffer' }) -- open actual new tab with leader-T -map('n', 'T', ':tabedit .') +map('n', 'T', ':tabedit | Vifm', { desc = 'open tab' }) -- select the whole buffer with -a -map('n', 'a', 'ggVG') +map('n', 'a', 'ggVG', { desc = 'select all' }) -- PLUGIN: Navigator.nvim -map('n', 'h', 'lua require("Navigator").left()', {silent = true}) -map('n', 'k', 'lua require("Navigator").up()', {silent = true}) -map('n', 'l', 'lua require("Navigator").right()', {silent = true}) -map('n', 'j', 'lua require("Navigator").down()', {silent = true}) -map('n', 'p', 'lua require("Navigator").previous()', {silent = true}) +map('n', 'h', 'lua require("Navigator").left()', { silent = true }) +map('n', 'k', 'lua require("Navigator").up()', { silent = true }) +map('n', 'l', 'lua require("Navigator").right()', { silent = true }) +map('n', 'j', 'lua require("Navigator").down()', { silent = true }) +map('n', 'p', 'lua require("Navigator").previous()', + { silent = true }) -- PLUGIN: Vifm.vim -- open/close file tree with leader-e -map('n', 'e', ':Vifm') +map('n', 'e', ':Vifm', { desc = 'browse files' }) -- open current file tree with current file directory -map('n', 'E', ':Vifm getcwd()') +map('n', 'E', ':Vifm getcwd()', { desc = 'browse project' }) -- PLUGIN: Telescope GLOBAL FUZZY FINDING -- buffers and files in current workdir -map('n', 's',":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())") +map('n', 's', + ":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())", + { desc = 'list buffers' }) -- most recently used / MRU, bound to S since it is essentially a larger -- go-back intention than just buffers -map('n', 'S',":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())") +map('n', 'S', + ":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())", + { desc = 'list old files' }) -- fuzzy find files in cwd -map('n', 'f',":lua require 'telescope.builtin'.find_files()") +map('n', 'f', ":lua require 'telescope.builtin'.find_files()", + { desc = 'find files' }) -- fuzzy find hidden files in cwd -map('n', '',":lua require 'telescope.builtin'.find_files({hidden=true})") +map('n', '', + ":lua require 'telescope.builtin'.find_files({hidden=true})", + { desc = 'find hidden files' }) -- general full-text search in cwd with rg -map('n', 'F',":lua require 'telescope.builtin'.live_grep()") +map('n', 'F', ":lua require 'telescope.builtin'.live_grep()", + { desc = 'grep search' }) -- git status -map('n', 'gs',":lua require 'telescope.builtin'.git_status()") +map('n', 'gs', ":lua require 'telescope.builtin'.git_status()", + { desc = 'git status' }) -- git buffercommits -map('n', 'gb',":lua require 'telescope.builtin'.git_bcommits()") +map('n', 'gb', ":lua require 'telescope.builtin'.git_bcommits()", + { desc = 'git buffer commits' }) -- git commitlog -map('n', 'gl',":lua require 'telescope.builtin'.git_commits()") +map('n', 'gl', ":lua require 'telescope.builtin'.git_commits()", + { desc = 'git commit log' }) -- helptags -map('n', '',":lua require 'telescope.builtin'.help_tags()") +map('n', '', ":lua require 'telescope.builtin'.help_tags()", + { desc = 'help tags' }) -- manpages -map('n', '',":lua require 'telescope.builtin'.man_pages()") +map('n', '', ":lua require 'telescope.builtin'.man_pages()", + { desc = 'man pages' }) -- colorschemes -map('n', '',":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())") +map('n', '', + ":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())", + { desc = 'colorschemes' }) -- spell suggestions -map('n', 'z=',":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())") - +map('n', 'z=', + ":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())") -- Format current Paragraph (esp useful in prose writing) -map('n', 'q', 'gqap', {silent=true}) -map('x', 'q', 'gq', {silent=true}) -map('n', 'Q', 'vapJgqap', {silent=true}) +map('n', 'q', 'gqap', + { silent = true, desc = 'Format current paragraph' }) +map('x', 'q', 'gq', { silent = true, desc = 'Format {motion}' }) +map('n', 'Q', 'vapJgqap', + { silent = true, desc = 'Unformat then format paragraph' }) -map('n', 'mp', 'MarkdownPreviewToggle') +map('n', 'mp', 'MarkdownPreviewToggle', + { desc = 'Toggle md preview' }) -- FORMAT code with -- PLUGIN: formatter.nvim @@ -158,17 +177,20 @@ map('n', 'f', ':FormatLock') map('n', 'F', ':FormatWriteLock') -- Enter distraction free prose mode with F11 -map('n', '', ':ZenMode', {silent=true}) +map('n', '', ':ZenMode', { silent = true }) -- SPELL CHECKING -- Move to the prev/next spelling error with [S ]S -- Move to the prev/next spelling error or suggestion with [s ]s -map('n', 'ZZ', ':setlocal spell! spelllang=en_us,de_de') -map('n', 'ZE', ':setlocal spell! spelllang=en_us') -map('n', 'ZG', ':setlocal spell! spelllang=de_de') +map('n', 'ZZ', ':setlocal spell! spelllang=en_us,de_de', + { desc = 'Toggle spellcheck' }) +map('n', 'ZE', ':setlocal spell! spelllang=en_us', + { desc = 'Toggle EN spellcheck' }) +map('n', 'ZG', ':setlocal spell! spelllang=de_de', + { desc = 'Toggle DE spellcheck' }) -- undo last spelling mistake from insert and normal mode map('i', '', 'u[s1z=`]au') -map('n', 's', 'ms[s1z=`s') +map('n', 's', 'ms[s1z=`s', { desc = 'Fix last spell error' }) -- PLUGIN: easy-align -- Start interactive EasyAlign in visual mode (e.g. vipga) @@ -178,22 +200,26 @@ map('n', 'ga', '(EasyAlign)') -- PLUGIN: vnsip -- jump around in snippets -map('i', '', [[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']], {expr=true}) -map('i', '', [[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']], {expr=true}) +map('i', '', [[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']], + { expr = true }) +map('i', '', + [[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']], + { expr = true }) -- PLUGIN: symbols-outline.nvim -map('n', 'o', 'SymbolsOutline', {silent=true}) +map('n', 'o', 'SymbolsOutline', { silent = true }) -- trim trailing whitespaces with mini.nvim trailspace -map("n", "w", function() require("mini.trailspace").trim() end, {noremap = true}) +map("n", "w", function() require("mini.trailspace").trim() end, + { noremap = true }) -- PLUGIN: dial-increment -map("n", "", require("dial.map").inc_normal(), {noremap = true}) -map("n", "", require("dial.map").dec_normal(), {noremap = true}) -map("v", "", require("dial.map").inc_visual(), {noremap = true}) -map("v", "", require("dial.map").dec_visual(), {noremap = true}) -map("v", "g",require("dial.map").inc_gvisual(), {noremap = true}) -map("v", "g",require("dial.map").dec_gvisual(), {noremap = true}) +map("n", "", require("dial.map").inc_normal(), { noremap = true }) +map("n", "", require("dial.map").dec_normal(), { noremap = true }) +map("v", "", require("dial.map").inc_visual(), { noremap = true }) +map("v", "", require("dial.map").dec_visual(), { noremap = true }) +map("v", "g", require("dial.map").inc_gvisual(), { noremap = true }) +map("v", "g", require("dial.map").dec_gvisual(), { noremap = true }) -- PLUGIN: zettelkasten.nvim map('n', '', [[:silent lua require 'zettelkasten'.link_follow()]]) @@ -206,22 +232,27 @@ map('n', 'G', ':Lazygit') -- PLUGIN: magma-nvim -- Operate jupyter notebooks from within vim -map('n', 'mm', ':MagmaEvaluateLine', {silent=true}) -map('n', 'M', '?^```{jV/```k:MagmaEvaluateVisual', {silent=true}) -map('x', 'm', ':MagmaEvaluateVisual', {silent=true}) -map('n', 'm', "nvim_exec('MagmaEvaluateOperator', v:true)", {expr=true, silent=true}) -map('n', 'mr', ':MagmaReevaluateCell', {silent=true}) -map('n', 'ma', ':MagmaShowOutput', {silent=true}) -map('n', 'mq', ':noautocmd :MagmaEnterOutput', {silent=true}) -map('n', 'md', ':MagmaDelete', {silent=true}) +map('n', 'mm', ':MagmaEvaluateLine', { silent = true }) +map('n', 'M', '?^```{jV/```k:MagmaEvaluateVisual', + { silent = true, desc = 'Evaluate current quarto cell' }) +map('x', 'm', ':MagmaEvaluateVisual', { silent = true }) +map('n', 'm', "nvim_exec('MagmaEvaluateOperator', v:true)", + { expr = true, silent = true }) +map('n', 'mr', ':MagmaReevaluateCell', { silent = true }) +map('n', 'ma', ':MagmaShowOutput', { silent = true }) +map('n', 'mq', ':noautocmd :MagmaEnterOutput', + { silent = true, desc = 'MagmaEnterOutput' }) +map('n', 'md', ':MagmaDelete', { silent = true }) map('n', 'ms', ':MagmaInterrupt') map('n', 'mI', ':MagmaInit ') map('n', 'mD', ':MagmaDeinit') map('n', 'mR', ':MagmaRestart') -- jump to beginning of previous/ next cell code -map('n', ']c', '/^```{}:nohl') -map('n', '[c', '?^```n}:nohl') +map('n', ']c', '/^```{}:nohl', { desc = 'Next quarto cell' }) +map('n', '[c', '?^```n}:nohl', { desc = 'Previous quarto cell' }) -- insert cell header above/below -map('n', 'mo', 'o```{python}```k') -map('n', 'mO', 'O```{python}```k') +map('n', 'mo', 'o```{python}```k', + { desc = 'Insert quarto cell below' }) +map('n', 'mO', 'O```{python}```k', + { desc = 'Insert quarto cell above' })