From 250e7f5666ec056bd5e3b83aa26f741fee5bb928 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Wed, 25 Sep 2024 14:52:56 +0300 Subject: [PATCH] feat(nvim): keymaps tweaks, cleanup, docs --- config/nvim/init.lua | 26 ++- config/nvim/lua/keymaps.lua | 72 ------ config/nvim/lua/options.lua | 6 + config/nvim/lua/plugins/cmp.lua | 4 +- config/nvim/lua/plugins/fzf.lua | 2 +- config/nvim/lua/plugins/git.lua | 1 + config/nvim/lua/plugins/goto-preview.lua | 3 +- config/nvim/lua/plugins/harpoon.lua | 12 +- config/nvim/lua/plugins/lazy.lua | 32 ++- config/nvim/lua/plugins/lsp.lua | 80 +++---- config/nvim/lua/plugins/telescope.lua | 18 +- config/nvim/lua/plugins/treesitter.lua | 8 +- config/nvim/lua/plugins/trouble.lua | 12 +- config/nvim/lua/plugins/ufo.lua | 21 +- config/nvim/lua/plugins/ui.lua | 18 +- config/nvim/lua/plugins/which-key.lua | 104 ++++++++- config/nvim/{lua => }/spell/en.utf-8.add | 0 docs/nvim-keybindings.md | 279 ++++++++++------------- 18 files changed, 345 insertions(+), 353 deletions(-) delete mode 100644 config/nvim/lua/keymaps.lua rename config/nvim/{lua => }/spell/en.utf-8.add (100%) diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 3030caf..fab758f 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -18,17 +18,29 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) -require 'options' -require 'keymaps' +-- Add ~/.local/bin to the PATH +vim.fn.setenv('PATH', vim.fn.expand '$HOME/.local/bin' .. ':' .. vim.fn.expand '$PATH') -require('lazy').setup { +require 'options' + +require('lazy').setup('plugins', { checker = { -- Automatically check for updates enabled = true, nofity = false, }, - spec = { - -- Import plugins from `lua/plugins` directory - { import = 'plugins' }, + change_detection = { + notify = false, }, -} +}) + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) diff --git a/config/nvim/lua/keymaps.lua b/config/nvim/lua/keymaps.lua deleted file mode 100644 index b638173..0000000 --- a/config/nvim/lua/keymaps.lua +++ /dev/null @@ -1,72 +0,0 @@ -vim.api.nvim_set_keymap('i', 'jj', '', { noremap = false }) - --- buffers -vim.api.nvim_set_keymap('n', 'bk', ':blast', { desc = 'Buffer: Last', noremap = false }) -vim.api.nvim_set_keymap('n', 'bj', ':bfirst', { desc = 'Buffer: First', noremap = false }) -vim.api.nvim_set_keymap('n', 'bh', ':bprev', { desc = 'Buffer: Prev', noremap = false }) -vim.api.nvim_set_keymap('n', 'bl', ':bnext', { desc = 'Buffer: Next', noremap = false }) -vim.api.nvim_set_keymap('n', 'bd', ':Bdelete', { desc = 'Buffer: Delete', noremap = false }) -vim.api.nvim_set_keymap('n', 'bw', ':Bwipeout', { desc = 'Buffer: Wipeout', noremap = false }) - --- files -vim.api.nvim_set_keymap('n', 'QQ', ':q!', { desc = 'Quickly Quit', noremap = false }) -vim.api.nvim_set_keymap('n', 'WW', ':w!', { desc = 'Force write', noremap = false }) -vim.api.nvim_set_keymap('n', 'E', '$', { noremap = false }) -vim.api.nvim_set_keymap('n', 'B', '^', { noremap = false }) -vim.api.nvim_set_keymap('n', 'tT', ':TransparentToggle', { desc = 'Toggle Transparency', noremap = true }) -vim.api.nvim_set_keymap('n', 'ss', ':noh', { noremap = true }) - --- splits -vim.api.nvim_set_keymap('n', ',', ':vertical resize -10', { desc = 'V Resize -', noremap = true }) -vim.api.nvim_set_keymap('n', '.', ':vertical resize +10', { desc = 'V Resize +', noremap = true }) - --- Quicker close split -vim.keymap.set('n', 'qf', ':q', { desc = 'Quicker close split', silent = true, noremap = true }) - --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - -vim.keymap.set('n', 'xe', 'GoIfErr', { desc = 'Go If Error', silent = true, noremap = true }) - --- TIP: Disable arrow keys in normal mode -vim.keymap.set('n', '', 'echo "Use h to move!!"') -vim.keymap.set('n', '', 'echo "Use l to move!!"') -vim.keymap.set('n', '', 'echo "Use k to move!!"') -vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- Old habits -vim.keymap.set('n', '', 'w', { desc = 'Save file' }) -vim.keymap.set('n', 'qq', 'wq!', { desc = '[qq] Quickly Quit' }) - --- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier --- for people to discover. Otherwise, you normally need to press , which --- is not what someone will guess without a bit more experience. --- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { - callback = function() - vim.highlight.on_yank() - end, - group = highlight_group, - pattern = '*', -}) diff --git a/config/nvim/lua/options.lua b/config/nvim/lua/options.lua index 9404b1f..796fc17 100644 --- a/config/nvim/lua/options.lua +++ b/config/nvim/lua/options.lua @@ -81,5 +81,11 @@ vim.o.termguicolors = true -- Set spell checking vim.o.spell = true +vim.o.spelllang = 'en_us' vim.g.loaded_perl_provider = 0 + +-- ── Deal with word wrap ─────────────────────────────────────────────────────── +local m = vim.api.nvim_set_keymap +m('n', 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Move up', noremap = true, expr = true }) +m('n', 'j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Move down', noremap = true, expr = true }) diff --git a/config/nvim/lua/plugins/cmp.lua b/config/nvim/lua/plugins/cmp.lua index 86feff1..b78aa77 100644 --- a/config/nvim/lua/plugins/cmp.lua +++ b/config/nvim/lua/plugins/cmp.lua @@ -31,7 +31,7 @@ return { help = true, }, }, - } + }, }, config = function() require('copilot_cmp').setup() @@ -51,7 +51,7 @@ return { min_width = 40, max_width = 100, symbol_map = { - Copilot = '' + Copilot = '', }, }, }, diff --git a/config/nvim/lua/plugins/fzf.lua b/config/nvim/lua/plugins/fzf.lua index 8e56e87..2f7258e 100644 --- a/config/nvim/lua/plugins/fzf.lua +++ b/config/nvim/lua/plugins/fzf.lua @@ -8,7 +8,7 @@ return { keys = { -- Stolen from https://github.com/erikw/dotfiles/blob/d68d6274d67ac47afa20b9a0b9f3b0fa54bcdaf3/.config/nvim/lua/plugins.lua -- Search for files in given path. - { '', ':FZF', desc = 'FZF: search for files in given path.' }, + { 'zf', ':FZF', desc = 'FZF: search for files in given path.' }, -- Sublime-like shortcut 'go to file' ctrl+p. { '', ':Files', desc = 'FZF: search for files starting at current directory.' }, { 'zc', ':Commands', desc = 'FZF: search commands.' }, diff --git a/config/nvim/lua/plugins/git.lua b/config/nvim/lua/plugins/git.lua index 90f30e7..0cf27e7 100644 --- a/config/nvim/lua/plugins/git.lua +++ b/config/nvim/lua/plugins/git.lua @@ -3,6 +3,7 @@ return { -- https://github.com/lewis6991/gitsigns.nvim { 'lewis6991/gitsigns.nvim', + lazy = false, config = function() require('gitsigns').setup { signs = { diff --git a/config/nvim/lua/plugins/goto-preview.lua b/config/nvim/lua/plugins/goto-preview.lua index c7f9fd9..3eeed00 100644 --- a/config/nvim/lua/plugins/goto-preview.lua +++ b/config/nvim/lua/plugins/goto-preview.lua @@ -6,9 +6,10 @@ return { { 'nvim-telescope/telescope.nvim' }, }, keys = { + { 'n', 'gp', group = 'Goto Preview' }, { 'n', 'gpd', 'lua require("goto-preview").goto_preview_definition()' }, { 'n', 'gpi', 'lua require("goto-preview").goto_preview_implementation()' }, - { 'n', 'gP', 'lua require("goto-preview").close_all_windows()' }, + { 'n', 'gpP', 'lua require("goto-preview").close_all_windows()' }, }, config = function() require('goto-preview').setup { diff --git a/config/nvim/lua/plugins/harpoon.lua b/config/nvim/lua/plugins/harpoon.lua index 1f1c76e..fd19e79 100644 --- a/config/nvim/lua/plugins/harpoon.lua +++ b/config/nvim/lua/plugins/harpoon.lua @@ -15,7 +15,7 @@ return { vim.keymap.set('n', 'ht', function() harpoon.ui:toggle_quick_menu(harpoon:list()) - end) + end, { desc = 'Open Harpoon Quick menu' }) -- basic telescope configuration local conf = require('telescope.config').values @@ -37,27 +37,27 @@ return { :find() end - vim.keymap.set('n', 'xa', function() + vim.keymap.set('n', 'hw', function() toggle_telescope(harpoon:list()) - end, { desc = 'Open harpoon window' }) + end, { desc = 'Open harpoon window with telescope' }) end, keys = { { - 'xa', + 'ha', function() require('harpoon'):list():add() end, desc = 'harpoon file', }, { - 'xN', + 'hp', function() require('harpoon'):list():prev() end, desc = 'harpoon to previous file', }, { - 'xn', + 'hn', function() require('harpoon'):list():next() end, diff --git a/config/nvim/lua/plugins/lazy.lua b/config/nvim/lua/plugins/lazy.lua index 772219e..7e299ad 100644 --- a/config/nvim/lua/plugins/lazy.lua +++ b/config/nvim/lua/plugins/lazy.lua @@ -1,16 +1,29 @@ return { - -- vscode-like pictograms for neovim lsp completion items - -- https://github.com/onsails/lspkind-nvim - { 'onsails/lspkind.nvim' }, + -- A better annotation generator. + -- Supports multiple languages and annotation conventions. + -- https://github.com/danymat/neogen + { + 'danymat/neogen', + version = '*', + keys = { + { + 'cg', + 'lua require("neogen").generate()', + desc = 'Generate annotations', + }, + }, + config = function() + require('neogen').setup { + enabled = true, + snippet_engine = 'luasnip', + } + end, + }, -- Rethinking Vim as a tool for writing -- https://github.com/preservim/vim-pencil { 'preservim/vim-pencil' }, - -- obsession.vim: continuously updated session files - -- https://github.com/tpope/vim-obsession - { 'tpope/vim-obsession' }, - -- surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease -- https://github.com/tpope/vim-surround { 'tpope/vim-surround' }, @@ -25,11 +38,6 @@ return { end, }, - -- LSP Configuration & Plugins - -- Meta type definitions for the Lua platform Luvit. - -- https://github.com/Bilal2453/luvit-meta - { 'Bilal2453/luvit-meta', lazy = true }, - -- Indent guides for Neovim -- https://github.com/lukas-reineke/indent-blankline.nvim { diff --git a/config/nvim/lua/plugins/lsp.lua b/config/nvim/lua/plugins/lsp.lua index d13cc25..b7d1316 100644 --- a/config/nvim/lua/plugins/lsp.lua +++ b/config/nvim/lua/plugins/lsp.lua @@ -1,65 +1,39 @@ -- Quickstart configs for Nvim LSP -- https://github.com/neovim/nvim-lspconfig return { - -- Neovim plugin to manage global and project-local settings - -- Should be included before LSP Config - -- https://github.com/folke/neoconf.nvim - { - 'folke/neoconf.nvim', - keys = { - { '?c', 'Neoconf', desc = 'Neoconf: Open' }, - { '?g', 'Neoconf global', desc = 'Neoconf: Global' }, - { '?l', 'Neoconf local', desc = 'Neoconf: Local' }, - { '?m', 'Neoconf lsp', desc = 'Neoconf: Show merged LSP config' }, - { '?s', 'Neoconf show', desc = 'Neoconf: Show merged config' }, - }, - config = function() - require('neoconf').setup() - end, - }, - { 'neovim/nvim-lspconfig', + lazy = false, dependencies = { + -- Neovim plugin to manage global and project-local settings + -- Should be included before LSP Config + -- https://github.com/folke/neoconf.nvim + { + 'folke/neoconf.nvim', + lazy = false, + keys = { + { '?c', 'Neoconf', desc = 'Neoconf: Open' }, + { '?g', 'Neoconf global', desc = 'Neoconf: Global' }, + { '?l', 'Neoconf local', desc = 'Neoconf: Local' }, + { '?m', 'Neoconf lsp', desc = 'Neoconf: Show merged LSP config' }, + { '?s', 'Neoconf show', desc = 'Neoconf: Show merged config' }, + }, + config = function() + require('neoconf').setup() + end, + }, -- Automatically install LSPs to stdpath for neovim - 'williamboman/mason.nvim', + { + 'williamboman/mason.nvim', + lazy = false, + run = ':call MasonUpdate', + }, 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - -- Useful status updates for LSP - { - 'j-hui/fidget.nvim', - opts = { - notification = { - window = { - winblend = 50, - align = 'top', - }, - }, - }, - }, 'b0o/schemastore.nvim', - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - dependencies = { - -- `wezterm-types` provides types for the Wezterm terminal - { - 'justinsgithub/wezterm-types', - as = 'wezterm', - }, - }, - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - -- Load wezterm types when the `wezterm` word is found - { path = 'wezterm-types', mods = { 'wezterm' } }, - }, - }, - }, - 'folke/neoconf.nvim', + -- vscode-like pictograms for neovim lsp completion items + -- https://github.com/onsails/lspkind-nvim + { 'onsails/lspkind.nvim' }, }, keys = { { 'do', 'lua vim.diagnostic.open_float()', desc = 'Diagnostic: Open float' }, @@ -215,7 +189,7 @@ return { end -- Turn on lsp status information - require('fidget').setup() + -- require('fidget').setup() -- Example custom configuration for lua -- diff --git a/config/nvim/lua/plugins/telescope.lua b/config/nvim/lua/plugins/telescope.lua index 0504f21..fb4249b 100644 --- a/config/nvim/lua/plugins/telescope.lua +++ b/config/nvim/lua/plugins/telescope.lua @@ -66,19 +66,17 @@ return { local wk = require 'which-key' wk.add { - -- { '', b.buffers, desc = '[ ] Find existing buffers' }, - { 'gR', "lua require('telescope').extensions.git_worktree.create_git_worktree()", desc = 'Create Git worktree' }, - { 'gr', "lua require('telescope').extensions.git_worktree.git_worktrees()", desc = 'Git worktrees' }, - { 'sS', b.git_status, desc = '' }, - { 'sd', b.diagnostics, desc = '[S]earch [D]iagnostics' }, - { 'sf', b.find_files, desc = '[S]earch [F]iles' }, - { 'sg', b.live_grep, desc = '[S]earch by [G]rep' }, + { '', b.buffers, desc = '[ ] Find existing buffers' }, + { '', "lua require('telescope.builtin').commands()", desc = 'Telescope: Commands' }, + { 'sS', b.git_status, desc = 'Git Status' }, + { 'sd', b.diagnostics, desc = 'Search Diagnostics' }, + { 'sf', b.find_files, desc = 'Search Files' }, + { 'sg', b.live_grep, desc = 'Search by Grep' }, { 'sm', ':Telescope harpoon marks', desc = 'Harpoon Marks' }, { 'sn', "lua require('telescope').extensions.notify.notify()", desc = 'Notify' }, - { 'so', b.oldfiles, desc = '[?] Find recently opened files' }, - { 'sw', b.grep_string, desc = '[S]earch current [W]ord' }, + { 'so', b.oldfiles, desc = 'Find recently Opened files' }, { 'st', ':TodoTelescope', desc = 'Telescope: Todo' }, - { '', "lua require('telescope.builtin').commands()", desc = 'Telescope: Commands' }, + { 'sw', b.grep_string, desc = 'Search current Word' }, } vim.keymap.set('n', '/', function() diff --git a/config/nvim/lua/plugins/treesitter.lua b/config/nvim/lua/plugins/treesitter.lua index 6a6da40..9ebc8f4 100644 --- a/config/nvim/lua/plugins/treesitter.lua +++ b/config/nvim/lua/plugins/treesitter.lua @@ -10,6 +10,10 @@ return { }, config = function() require('nvim-treesitter.configs').setup { + auto_install = true, + ignore_install = {}, + sync_install = true, + modules = {}, -- Add languages to be installed here that you want installed for treesitter ensure_installed = { @@ -95,10 +99,10 @@ return { swap = { enable = true, swap_next = { - ['a'] = '@parameter.inner', + ['cn'] = '@parameter.inner', }, swap_previous = { - ['A'] = '@parameter.inner', + ['cP'] = '@parameter.inner', }, }, }, diff --git a/config/nvim/lua/plugins/trouble.lua b/config/nvim/lua/plugins/trouble.lua index 07bdf92..190a624 100644 --- a/config/nvim/lua/plugins/trouble.lua +++ b/config/nvim/lua/plugins/trouble.lua @@ -3,12 +3,12 @@ return { lazy = false, dependencies = 'nvim-tree/nvim-web-devicons', keys = { - { 'xx', 'TroubleToggle', desc = 'Toggle Trouble' }, - { 'xw', 'TroubleToggle workspace_diagnostics', desc = 'Toggle Workspace Diagnostics' }, - { 'xd', 'TroubleToggle document_diagnostics', desc = 'Toggle Document Diagnostics' }, - { 'xl', 'TroubleToggle loclist', desc = 'Toggle Loclist' }, - { 'xq', 'TroubleToggle quickfix', desc = 'Toggle Quickfix' }, - { 'gR', 'TroubleToggle lsp_references', desc = 'Toggle LSP References' }, + { 'xx', 'Trouble', desc = 'Toggle Trouble' }, + { 'xw', 'Trouble workspace_diagnostics', desc = 'Toggle Workspace Diagnostics' }, + { 'xd', 'Trouble document_diagnostics', desc = 'Toggle Document Diagnostics' }, + { 'xl', 'Trouble loclist', desc = 'Toggle Loclist' }, + { 'xq', 'Trouble quickfix', desc = 'Toggle Quickfix' }, + { 'gR', 'Trouble lsp_references', desc = 'Toggle LSP References' }, }, config = function() require('trouble').setup { diff --git a/config/nvim/lua/plugins/ufo.lua b/config/nvim/lua/plugins/ufo.lua index 864aeb6..ce10f94 100644 --- a/config/nvim/lua/plugins/ufo.lua +++ b/config/nvim/lua/plugins/ufo.lua @@ -1,3 +1,22 @@ +-- Not UFO in the sky, but an ultra fold in Neovim. +-- https://github.com/kevinhwang91/nvim-ufo/ + +-- fold_virt_text_handler +-- This handler is called when the fold text is too long to fit in the window. +-- It is expected to truncate the text and return a new list of virtual text. +-- The handler is called with the following arguments: +-- virtText: The current virtual text list. +-- lnum: The line number of the first line in the fold. +-- endLnum: The line number of the last line in the fold. +-- width: The width of the window. +-- +--@type function +--@param virtText +--@param lnum +--@param endLnum +--@param width +--@param truncate +--@return table local handler = function(virtText, lnum, endLnum, width, truncate) local newVirtText = {} local suffix = (' 󰁂 %d '):format(endLnum - lnum) @@ -27,8 +46,6 @@ local handler = function(virtText, lnum, endLnum, width, truncate) end return { - -- Not UFO in the sky, but an ultra fold in Neovim. - -- https://github.com/kevinhwang91/nvim-ufo/ { 'kevinhwang91/nvim-ufo', lazy = false, diff --git a/config/nvim/lua/plugins/ui.lua b/config/nvim/lua/plugins/ui.lua index 08f7bbf..a1a7ab7 100644 --- a/config/nvim/lua/plugins/ui.lua +++ b/config/nvim/lua/plugins/ui.lua @@ -72,6 +72,9 @@ return { enabled = true, lazy = false, version = '*', + keys = { + { 'tc', 'CloakToggle', desc = '[tc] Toggle Cloak' }, + }, config = function() require('cloak').setup { enabled = true, @@ -95,9 +98,6 @@ return { }, } end, - keys = { - { 'tc', 'CloakToggle', desc = '[tc] Toggle Cloak' }, - }, }, -- Close buffer without messing up with the window. -- https://github.com/famiu/bufdelete.nvim @@ -125,18 +125,6 @@ return { { 'LudoPinelli/comment-box.nvim', opts = {}, - init = function() - local wk = require 'which-key' - - wk.add { - { 'cb', group = 'CommentBox' }, - { 'cbb', 'CBccbox', desc = 'CommentBox: Box Title' }, - { 'cbd', 'CBd', desc = 'CommentBox: Remove a box' }, - { 'cbl', 'CBline', desc = 'CommentBox: Simple Line' }, - { 'cbm', 'CBllbox14', desc = 'CommentBox: Marked' }, - { 'cbt', 'CBllline', desc = 'CommentBox: Titled Line' }, - } - end, }, -- Automatically expand width of the current window. -- Maximizes and restore it. And all this with nice animations! diff --git a/config/nvim/lua/plugins/which-key.lua b/config/nvim/lua/plugins/which-key.lua index 11f0ad8..9ea35af 100644 --- a/config/nvim/lua/plugins/which-key.lua +++ b/config/nvim/lua/plugins/which-key.lua @@ -14,7 +14,14 @@ return { wk.setup() wk.add { - -- Groups + -- Better default experience + { '', '', mode = { 'n', 'v' } }, + + -- ╭─────────────────────────────────────────────────────────╮ + -- │ With leader │ + -- ╰─────────────────────────────────────────────────────────╯ + + -- ── Buffer ────────────────────────────────────────────────────────── { 'b', group = '[b] Buffer', @@ -22,17 +29,54 @@ return { return require('which-key.extras').expand.buf() end, }, + { 'bk', ':blast', desc = 'Buffer: Last', mode = 'n' }, + { 'bj', ':bfirst', desc = 'Buffer: First', mode = 'n' }, + { 'bh', ':bprev', desc = 'Buffer: Prev', mode = 'n' }, + { 'bl', ':bnext', desc = 'Buffer: Next', mode = 'n' }, + { 'bd', ':Bdelete', desc = 'Buffer: Delete', mode = 'n' }, + { 'bw', ':Bwipeout', desc = 'Buffer: Wipeout', mode = 'n' }, + + -- ── Code ──────────────────────────────────────────────────────────── { 'c', group = '[c] Code' }, - { 'd', group = '[d] Document' }, + -- ── Code: CommentBox ──────────────────────────────────────────────── + { 'cb', group = 'CommentBox' }, + { 'cbb', 'CBccbox', desc = 'CommentBox: Box Title' }, + { 'cbd', 'CBd', desc = 'CommentBox: Remove a box' }, + { 'cbl', 'CBline', desc = 'CommentBox: Simple Line' }, + { 'cbm', 'CBllbox14', desc = 'CommentBox: Marked' }, + { 'cbt', 'CBllline', desc = 'CommentBox: Titled Line' }, + + { 'd', group = '[d] DAP' }, + -- See: lua/plugins/dap.lua + { 'g', group = '[g] Git' }, + -- See: lua/plugins/git.lua + + { 'h', group = '[h] Harpoon' }, + -- See: lua/plugins/harpoon.lua + { 'l', group = '[l] LSP' }, - { 'p', group = '[p] Project' }, + -- See: lua/plugins/lsp.lua + + -- ── Quit ──────────────────────────────────────────────────────────── { 'q', group = '[q] Quit' }, + { 'qf', ':q', desc = 'Quicker close split' }, + { 'qq', ':wq!', desc = 'Quit with force saving' }, + { 'qw', ':wq', desc = 'Write and quit' }, + { 's', group = '[s] Search' }, + -- See: lua/plugins/telescope.lua + + -- ── Toggle ────────────────────────────────────────────────────────── { 't', group = '[t] Toggle' }, + { 'tt', ':TransparentToggle', desc = 'Toggle Transparency' }, + { 'ts', ':noh', desc = 'Toggle Search Highlighting' }, + { 'w', group = '[w] Workspace' }, - { 'x', group = '[z] Trouble' }, - { 'z', group = '[x] FZF & Harpoon' }, + { 'x', group = '[x] Trouble' }, + { 'z', group = '[z] FZF' }, + + -- ── Help ──────────────────────────────────────────────────────────── { '?', group = '[?] Help' }, { '?w', @@ -41,8 +85,56 @@ return { end, desc = 'Buffer Local Keymaps (which-key)', }, - -- Misc keybinds + + -- ╭─────────────────────────────────────────────────────────╮ + -- │ Without leader │ + -- ╰─────────────────────────────────────────────────────────╯ + { 'y', group = 'Yank & Surround' }, + + -- ── Old habits ────────────────────────────────────────────────────── + { '', ':w', desc = 'Save file' }, + + -- ── Text manipulation in visual mode ──────────────────────────────── + { '>', '>gv', desc = 'Indent Right', mode = 'v' }, + { '<', '+1gv=gv", desc = 'Move Block Down', mode = 'v' }, + { 'K', ":m '<-2gv=gv", desc = 'Move Block Up', mode = 'v' }, + + -- ── Misc keybinds ─────────────────────────────────────────────────── { 'QQ', ':q!', desc = 'Quit without saving' }, + { 'WW', ':w!', desc = 'Force write to file' }, + { 'ss', ':noh', desc = 'Clear Search Highlighting' }, + { 'jj', '', desc = 'Esc without touching esc in insert mode', mode = 'i' }, + + -- ── Splits ────────────────────────────────────────────────────────── + -- Use CTRL+ to switch between windows in normal mode + -- See `:help wincmd` for a list of all window commands + { '', '', desc = 'Move focus to the left window' }, + { '', '', desc = 'Move focus to the right window' }, + { '', '', desc = 'Move focus to the lower window' }, + { '', '', desc = 'Move focus to the upper window' }, + -- Split resizing + { ',', ':vertical resize -10', desc = 'V Resize -' }, + { '.', ':vertical resize +10', desc = 'V Resize +' }, + + -- ── Disable arrow keys in normal mode ─────────────────────────────── + { '', 'echo "Use h to move!!"' }, + { '', 'echo "Use l to move!!"' }, + { '', 'echo "Use k to move!!"' }, + { '', 'echo "Use j to move!!"' }, + + -- ── Terminal ──────────────────────────────────────────────────────── + -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier + -- for people to discover. Otherwise, you normally need to press , which + -- is not what someone will guess without a bit more experience. + -- + -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping + -- or just use to exit terminal mode. + { '', '', desc = 'Exit terminal mode', mode = 't' }, + + -- ── Search ────────────────────────────────────────────────────────── + -- :noh if you have search highlights + { '', ':noh', desc = 'Clear search highlights' }, } end, } diff --git a/config/nvim/lua/spell/en.utf-8.add b/config/nvim/spell/en.utf-8.add similarity index 100% rename from config/nvim/lua/spell/en.utf-8.add rename to config/nvim/spell/en.utf-8.add diff --git a/docs/nvim-keybindings.md b/docs/nvim-keybindings.md index ab6aaa1..4d36ceb 100644 --- a/docs/nvim-keybindings.md +++ b/docs/nvim-keybindings.md @@ -2,101 +2,98 @@ ```txt -n zg * :Rg - FZF: search with rg (aka live grep). -n zm * :Maps - FZF: search mappings. -n zh * :History - FZF: search history of opened files -n zb * :Buffers - FZF: search open buffers. -n zt * :Windows - FZF: search open tabs. -n zc * :Commands - FZF: search commands. -n zf * :FZF - FZF: search for files in given path. +n / * + [/] Fuzzily search in current buffer] +n hw * + Open harpoon window with telescope +n 1 * + harpoon to file 1 +n hn * + harpoon to next file +n hp * + harpoon to previous file +n ha * + harpoon file +n 5 * + harpoon to file 5 +n 4 * + harpoon to file 4 +n 3 * + harpoon to file 3 +n 2 * + harpoon to file 2 n tc * CloakToggle [tc] Toggle Cloak -n / * - [/] Fuzzily search in current buffer] -n ht * -n 1 * - harpoon to file 1 -n xn * - harpoon to next file -n xN * - harpoon to previous file -n xa * - Open harpoon window -n 5 * - harpoon to file 5 -n 4 * - harpoon to file 4 -n 3 * - harpoon to file 3 -n 2 * - harpoon to file 2 -n gB * :G blame -n gb * :Telescope git_branches -n gP * :Neogit push -n gp * :Neogit pull -n gc * :Neogit commit -n gs * -n e * - NeoTree reveal -n ca * - LSP: Code Action -n wl * - LSP: Workspace List Folders -n wr * - LSP: Workspace Remove Folder -n wa * - LSP: Workspace Add Folder -n ws * - LSP: Workspace Symbols -n D * - LSP: Type Definition -n dq * - Diagnostic: Set loc list -n do * - Diagnostic: Open float -n cr * - LSP: Rename -n ds * - LSP: Document Symbols -n ?s * +n xx * Trouble + Toggle Trouble +n xq * Trouble quickfix + Toggle Quickfix +n xl * Trouble loclist + Toggle Loclist +n xd * Trouble document_diagnostics + Toggle Document Diagnostics +n xw * Trouble workspace_diagnostics + Toggle Workspace Diagnostics +n ?s * Neoconf show Neoconf: Show merged config -n ?m * +n ?m * Neoconf lsp Neoconf: Show merged LSP config -n ?l * +n ?l * Neoconf local Neoconf: Local -n ?g * +n ?g * Neoconf global Neoconf: Global -n ?c * +n ?c * Neoconf Neoconf: Open - f * +n wl * lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + LSP: Workspace List Folders +n wr * lua vim.lsp.buf.remove_workspace_folder() + LSP: Workspace Remove Folder +n wa * lua vim.lsp.buf.add_workspace_folder() + LSP: Workspace Add Folder +n ws * lua require("telescope.builtin").lsp_dynamic_workspace_symbols() + LSP: Workspace Symbols +n ds * lua require("telescope.builtin").lsp_document_symbols() + LSP: Document Symbols +n D * lua vim.lsp.buf.type_definition() + LSP: Type Definition +n ca * lua vim.lsp.buf.code_action() + LSP: Code Action +n cr * lua vim.lsp.buf.rename() + LSP: Rename +n dq * lua vim.diagnostic.setloclist() + Diagnostic: Set loc list +n do * lua vim.diagnostic.open_float() + Diagnostic: Open float + cf * [f] Format buffer -n qq * wq! - [qq] Quickly Quit -n xe * GoIfErr - Go If Error -v * -n * -n qf * :q - Quicker close split -n bw :Bwipeout - Buffer: Wipeout -n bd :Bdelete - Buffer: Delete -n bl :bnext - Buffer: Next -n bh :bprev - Buffer: Prev -n bj :bfirst - Buffer: First -n bk :blast - Buffer: Last +n e * + NeoTree reveal +n cg * + Generate annotations +n zm * + FZF: search mappings. +n zh * + FZF: search history of opened files +n zb * + FZF: search open buffers. +n zt * + FZF: search open tabs. +n zc * + FZF: search commands. +n zf * + FZF: search for files in given path. +n zg * + FZF: search with rg (aka live grep). +n dc * + DAP: Continue +n db * + DAP: Toggle Breakpoint +n dt * + DAP: Toggle UI +n ht * + Open Harpoon Quick menu +n dr * + DAP: Reset x # * :help v_#-default o % (MatchitOperationForward) @@ -108,17 +105,11 @@ x * * :help v_star-default x @ * mode() == 'V' ? ':normal! @'.getcharstr().'' : '@' :help v_@-default -n B ^ -n E $ -n K * +n K * lua vim.lsp.buf.hover() LSP: Hover Documentation -n QQ :q! - Quickly Quit x Q * mode() == 'V' ? ':normal! @=reg_recorded()' : 'Q' :help v_Q-default x S VSurround -n WW :w! - Force write n Y * y$ :help Y-default o [% (MatchitOperationMultiBackward) @@ -135,36 +126,24 @@ x a% (MatchitVisualTextObject) n cS CSurround n cs Csurround n ds Dsurround -n dn * - Diagnostic: Goto Next -n dp * +n dp * lua vim.diagnostic.goto_prev() Diagnostic: Goto Prev +n dn * lua vim.diagnostic.goto_next() + Diagnostic: Goto Next o g% (MatchitOperationBackward) x g% (MatchitVisualBackward) n g% (MatchitNormalBackward) x gS VgSurround -n gP * - Close preview windows -n gpr * - Preview references -n gpD * - Preview declaration -n gpi * - Preview implementation -n gpt * - Preview type definition -n gpd * - Preview definition n gR * :RegexplainerToggle Toggle Regexplainer -n gd * - LSP: Goto Definition -n gr * - LSP: Goto References -n gI * - LSP: Goto Implementation -n gD * +n gD * lua vim.lsp.buf.declaration() LSP: Goto Declaration +n gd * lua vim.lsp.buf.definition() + LSP: Goto Definition +n gr * lua require("telescope.builtin").lsp_references() + LSP: Goto References +n gI * lua vim.lsp.buf.implementation() + LSP: Goto Implementation o gc * Comment textobject n gcc * @@ -178,12 +157,11 @@ x gx * n gx * Opens filepath or URI under cursor with the system handler (file explorer, web browser, …) n j * v:count == 0 ? 'gj' : 'j' + Move down n k * v:count == 0 ? 'gk' : 'k' -n n * + Move up +n n * Twilight -n ss * :noh -n tT * :TransparentToggle - Toggle Transparency n ySS YSsurround n ySs YSsurround n yss Yssurround @@ -202,59 +180,44 @@ x (MatchitVisualBackward) * :call matchit#Match_wrapper('',0,'v')(MatchitVisualForward) * :call matchit#Match_wrapper('',1,'v'):if col("''") != col("$") | exe ":normal! m'" | endifgv`` n (MatchitNormalBackward) * :call matchit#Match_wrapper('',0,'n') n (MatchitNormalForward) * :call matchit#Match_wrapper('',1,'n') +v VgSurround * :call 27_opfunc(visualmode(),visualmode() ==# 'V' ? 0 : 1) +v VSurround * :call 27_opfunc(visualmode(),visualmode() ==# 'V' ? 1 : 0) +n YSurround * 27_opfunc2('setup') +n Ysurround * 27_opfunc('setup') +n YSsurround * 27_opfunc2('setup').'_' +n Yssurround * '^'.v:count1.27_opfunc('setup').'g_' +n CSurround * :call 27_changesurround(1) +n Csurround * :call 27_changesurround() +n Dsurround * :call 27_dosurround(27_inputtarget()) +n SurroundRepeat * . +n * :TmuxNavigateRight n * :TmuxNavigatePrevious n * :TmuxNavigateDown -n * :TmuxNavigateRight n * :TmuxNavigateLeft -v VgSurround * :call 28_opfunc(visualmode(),visualmode() ==# 'V' ? 0 : 1) -v VSurround * :call 28_opfunc(visualmode(),visualmode() ==# 'V' ? 1 : 0) -n YSurround * 28_opfunc2('setup') -n Ysurround * 28_opfunc('setup') -n YSsurround * 28_opfunc2('setup').'_' -n Yssurround * '^'.v:count1.28_opfunc('setup').'g_' -n CSurround * :call 28_changesurround(1) -n Csurround * :call 28_changesurround() -n Dsurround * :call 28_dosurround(28_inputtarget()) -n SurroundRepeat * . -n * :Files - FZF: search for files starting at current directory. -o (fzf-maps-o) * :call fzf#vim#maps('o', 0) -x (fzf-maps-x) * :call fzf#vim#maps('x', 0) -n (fzf-maps-n) * :call fzf#vim#maps('n', 0) -n (fzf-normal) * -n (fzf-insert) * i -s luasnip-jump-prev * +n * :TmuxNavigateUp +s luasnip-jump-prev * LuaSnip: Jump to the previous node -s luasnip-jump-next * +s luasnip-jump-next * LuaSnip: Jump to the next node -s luasnip-prev-choice * +s luasnip-prev-choice * LuaSnip: Change to the previous choice from the choiceNode -s luasnip-next-choice * +s luasnip-next-choice * LuaSnip: Change to the next choice from the choiceNode -s luasnip-expand-snippet * +s luasnip-expand-snippet * LuaSnip: Expand the current snippet -s luasnip-expand-or-jump * +s luasnip-expand-or-jump * LuaSnip: Expand or jump in the current snippet - luasnip-expand-repeat * + luasnip-expand-repeat * LuaSnip: Repeat last node expansion -n luasnip-delete-check * +n luasnip-delete-check * LuaSnip: Removes current snippet from jumplist n PlenaryTestFile * :lua require('plenary.test_harness').test_file(vim.fn.expand("%:p")) -n * w - Save file -n * :TmuxNavigateUp -n * echo "Use j to move!!" -n * echo "Use k to move!!" -n * echo "Use l to move!!" -n * echo "Use h to move!!" -n . * :vertical resize +10 - V Resize + -n , * :vertical resize -10 - V Resize - +n * + FZF: search for files starting at current directory. n d Show diagnostics under the cursor n d * Show diagnostics under the cursor ``` -- Generated on Mon 23 Sep 2024 10:24:56 EEST +- Generated on Wed 25 Sep 2024 14:52:25 EEST