-- highlighting yanked regions 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, }) local m = require 'mapx'.setup { global = true, whichkey = true } -- unmap unwanted commands m.nnoremap("", '') m.inoremap("", '') m.nnoremap("", '') m.inoremap("", '') m.inoremap("", '') m.inoremap("", '') m.inoremap("", '') m.inoremap("", '') m.inoremap("", '') m.inoremap("", '') m.nnoremap("", '') m.inoremap("", '') m.nnoremap("", '') 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') -- compiler for languages 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') -- 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') -- stevearc/aerial.nvim m.nmap('', ':AerialToggle!', 'Aerial: Open side window') -- nvim-tree/nvim-tree.lua m.nmap("", ':NvimTreeToggle toggle', 'NvimTree: 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") 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.nname("gd", "Git Diff") m.nmap("gdo", ":DiffviewOpen", "Git Diff: open") m.nmap("gdc", ":DiffviewClose", "Git Diff: close") -- folke/trouble.nvim m.nmap("x", ":TroubleToggle", "Trouble: toggle") -- 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("gi", vim.lsp.buf.implementation, "LSP: list implementation") m.nnoremap("gr", vim.lsp.buf.references, "LSP: list references") m.nnoremap("K", vim.lsp.buf.hover, "LSP: show documentation") m.nnoremap("", function() require("conform").format({ async = true, lsp_fallback = true }) end, "LSP: format") -- filipdutescu/renamer.nvim m.nnoremap("", require("renamer").rename, "LSP: rename") -- nvim-telescope/telescope.nvim m.nnoremap("", ':Telescope find_files', "Telescope: find files") -- kamykn/spelunker.vim m.nnoremap("", ':call spelunker#toggle()', "Spelunker: toggle") -- kevinhwang91/nvim-ufo m.nnoremap("K", function() local winid = require('ufo').peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end, "UFO: peek folded section") -- kevinhwang91/nvim-hlslens m.nnoremap("n", [[execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()]], 'silent', "HLSens: search forward") m.nnoremap("N", [[execute('normal! ' . v:count1 . 'N')lua require('hlslens').start()]], 'silent', "HLSens: search backwards")