diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 7d66ef7..fcf6117 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -9,6 +9,7 @@ "comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "conform.nvim": { "branch": "master", "commit": "8b407bb6175846cdc4c499e2a8d28109615a2089" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, + "dressing.nvim": { "branch": "master", "commit": "8b7ae53d7f04f33be3439a441db8071c96092d19" }, "fterm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" }, "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, "git-blame.nvim": { "branch": "master", "commit": "f07e913b7143f19edd6787229f2d51759b478600" }, @@ -16,10 +17,12 @@ "indent-blankline.nvim": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" }, "knap": { "branch": "main", "commit": "503010f541696e99ed5c62f658620e546cebf8b0" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "legendary.nvim": { "branch": "master", "commit": "234e2ef8dec65db153c63a8b310c74155bb93ee7" }, "lsp_signature.nvim": { "branch": "master", "commit": "fed2c8389c148ff1dfdcdca63c2b48d08a50dea0" }, "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, "luasnip": { "branch": "master", "commit": "954c81b53989097faaff0fabc11c29575288c3e1" }, + "mapx.nvim": { "branch": "main", "commit": "c3dd43474a5fc2f266309bc04a69b74eb2524671" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" }, "mason-null-ls.nvim": { "branch": "main", "commit": "d1f7258f80867f718d643d88eee66959671a4bef" }, "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, @@ -54,5 +57,6 @@ "vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" }, "vim-markdown": { "branch": "master", "commit": "46add6c3017d3e4035dc10ffa9cb54221d8dfe1a" }, "vim-renamer": { "branch": "master", "commit": "9c6346eb4556cf2d8ca55de6969247ab14fe2383" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" } } \ No newline at end of file diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index e38cd89..c9ddf8a 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -7,9 +7,21 @@ vim.api.nvim_create_autocmd('TextYankPost', { group = highlight_group, }) +-- setup keymap function local m = require 'mapx'.setup { global = true, whichkey = true } +-- setup keymap groups +m.nname("g", "LSP: goto") +m.cname("w", "Write") +m.cname("w!", "Write: overwrite") +m.nname("g", "Git") +m.nname("gd", "Git: diff") +m.nname("s", "Substitute") +m.nname("t", "Terminal") + -- unmap unwanted commands +m.nnoremap("Zt", '') +m.nnoremap("ZT", '') m.nnoremap("", '') m.inoremap("", '') m.nnoremap("", '') @@ -27,67 +39,57 @@ m.inoremap("", '') m.nnoremap("", '') m.inoremap("", '') m.nnoremap("", '') -m.nnoremap("ZT", '') -m.nnoremap("Zt", '') -- shortcut for split navigation -m.nnoremap("", 'h', 'splits: go to left split') -m.nnoremap("", 'j', 'splits: go to lower split') -m.nnoremap("", 'k', 'splits: go to upper split') -m.nnoremap("", 'l', 'splits: go to right split') +m.nnoremap("", 'h', 'Navigation: go to left split') +m.nnoremap("", 'j', 'Navigation: go to lower split') +m.nnoremap("", 'k', 'Navigation: go to upper split') +m.nnoremap("", 'l', 'Navigation: go to right split') + +-- remap for dealing with word wrap +m.nmap('j', "v:count == 0 ? 'gj' : 'j'", { "expr", "silent" }, 'Navigation: go down in wrapped lines') +m.nmap('k', "v:count == 0 ? 'gk' : 'k'", { "expr", "silent" }, 'Navigation: go up in wrapped lines') -- compiler for languages -m.nnoremap("c", ':w! | !compiler %', 'Compile current file') +m.nnoremap("c", ':w! | !compiler %', 'Compile: current file') -- save file as sudo on files that require root permission -m.cname("w", "Write") -m.cname("w!", "Write with sudo") -m.cnoremap("w!!", 'execute "silent! write !sudo tee % >/dev/null" edit!', 'Write file over with sudo') +m.cnoremap("w!!", 'execute "silent! write !sudo tee % >/dev/null" edit!', 'Write: overwrite file over with sudo') -- easy substitution for whole file and line, visual mode -m.nname("s", "Substitute") -m.nnoremap("ss", ':%s/\\<\\>//g', 'Substitute: word under cursor') m.nnoremap("sa", ':%s//g', 'Substitute: free form') - --- remap for dealing with word wrap -m.nmap('k', "v:count == 0 ? 'gk' : 'k'", { "expr", "silent" }, 'go up in wrapped lines') - -m.nmap('j', "v:count == 0 ? 'gj' : 'j'", { "expr", "silent" }, 'go down in wrapped lines') +m.nnoremap("ss", ':%s/\\<\\>//g', 'Substitute: word under cursor') -- stevearc/aerial.nvim -m.nmap('', ':AerialToggle!', 'Aerial: Open side window') +m.nmap('', ':AerialToggle!', 'CTags: toggle') -- nvim-tree/nvim-tree.lua -m.nmap("", ':NvimTreeToggle toggle', 'NvimTree: toggle') +m.nmap("", ':NvimTreeToggle toggle', 'File tree: toggle') -- numtostr/fterm.nvim -m.nname("t", "FTerm") -m.nnoremap("tt", require("FTerm").toggle, 'Terminal: toggle') -m.tnoremap("tt", require("FTerm").toggle, 'Terminal: toggle') - - --- sindrets/diffview.nvim -m.nname("g", "Git") +m.nnoremap("tt", require("FTerm").toggle, 'Terminal: open') +m.tnoremap("tt", require("FTerm").toggle, 'Terminal: open') local lazygit = require("FTerm"):new({ cmd = 'lazygit', }) -m.nnoremap("tg", function() lazygit:toggle() end, 'Lazygit: toggle') -m.tnoremap("tg", function() lazygit:toggle() end, 'Lazygit: toggle') +m.nnoremap("gt", function() lazygit:toggle() end, 'Git: open lazygit') +m.tnoremap("gt", function() lazygit:toggle() end, 'Git: open lazygit') +m.nnoremap("tg", function() lazygit:toggle() end, 'Terminal: open lazygit') +m.tnoremap("tg", function() lazygit:toggle() end, 'Terminal: open lazygit') -m.nname("gd", "Git Diff") -m.nmap("gdo", ":DiffviewOpen", "Git Diff: open") -m.nmap("gdc", ":DiffviewClose", "Git Diff: close") +-- sindrets/diffview.nvim +m.nmap("gdo", ":DiffviewOpen", "Git: open diff") +m.nmap("gdc", ":DiffviewClose", "Git: close diff") -- folke/trouble.nvim -m.nmap("x", ":TroubleToggle", "Trouble: toggle") +m.nmap("x", ":TroubleToggle", "LSP: toggle error list") -- hrsh7th/nvim-cmp -m.nname("g", "LSP: goto") -m.nnoremap("gD", vim.lsp.buf.declaration, "LSP: goto declaration") m.nnoremap("gd", vim.lsp.buf.definition, "LSP: goto definition") -m.nnoremap("gy", vim.lsp.buf.type_definition, "LSP: goto type definition") +m.nnoremap("gD", vim.lsp.buf.declaration, "LSP: goto declaration") m.nnoremap("gi", vim.lsp.buf.implementation, "LSP: list implementation") m.nnoremap("gr", vim.lsp.buf.references, "LSP: list references") +m.nnoremap("gy", vim.lsp.buf.type_definition, "LSP: goto type definition") m.nnoremap("K", vim.lsp.buf.hover, "LSP: show documentation") m.nnoremap("", function() require("conform").format({ async = true, lsp_fallback = true }) end, "LSP: format") @@ -98,7 +100,7 @@ m.nnoremap("", require("renamer").rename, "LSP: rename") m.nnoremap("", ':Telescope find_files', "Telescope: find files") -- kamykn/spelunker.vim -m.nnoremap("", ':call spelunker#toggle()', "Spelunker: toggle") +m.nnoremap("", ':call spelunker#toggle()', "Spelling: toggle spell check") -- kevinhwang91/nvim-ufo m.nnoremap("K", function() @@ -106,10 +108,10 @@ m.nnoremap("K", function() if not winid then vim.lsp.buf.hover() end -end, "UFO: peek folded section") +end, "LSP: peek folded section") -- kevinhwang91/nvim-hlslens m.nnoremap("n", [[execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()]], - 'silent', "HLSens: search forward") + 'silent', "Search: search forward") m.nnoremap("N", [[execute('normal! ' . v:count1 . 'N')lua require('hlslens').start()]], - 'silent', "HLSens: search backwards") + 'silent', "Search: search backwards")