-- 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, }) -- setup keymap function local m = require 'mapx'.setup { global = true, whichkey = true } -- setup keymap groups m.nname("g", "LSP: goto") m.nname("gp", "LSP: preview") 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") m.nname("", "Navigation") -- unmap unwanted commands m.nnoremap("Zt", '') m.nnoremap("ZT", '') 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("", '') -- shortcut for split navigation m.nnoremap("", 'h', 'Navigation: go to left window') m.nnoremap("", 'j', 'Navigation: go to lower window') m.nnoremap("", 'k', 'Navigation: go to upper window') m.nnoremap("", 'l', 'Navigation: go to right window') -- 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') -- save file as sudo on files that require root permission m.cnoremap("w!!", 'execute "silent! write !sudo tee % >/dev/null" edit!', 'Write: overwrite file over with sudo') -- tpope/vim-abolish m.nnoremap("sa", ':%S//g', 'Substitute: free form') m.nnoremap("ss", ':%S/\\<\\>//g', 'Substitute: word under cursor') -- simrat39/symbols-outline.nvim m.nmap('', ':SymbolsOutline', 'CTags: toggle') -- nvim-tree/nvim-tree.lua m.nmap("", ':NvimTreeToggle toggle', 'File tree: toggle') -- mbbill/undotree m.nmap("", ':UndotreeToggle', 'Undo tree: toggle') -- amrbashir/nvim-docs-view m.nnoremap("go", ':DocsViewToggle', 'LSP: toggle documentation window') -- numtostr/fterm.nvim 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("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') -- sindrets/diffview.nvim m.nmap("gdo", ":DiffviewOpen", "Git: open diff") m.nmap("gdc", ":DiffviewClose", "Git: close diff") -- folke/trouble.nvim m.nmap("x", ":TroubleToggle", "LSP: toggle error list") -- hrsh7th/nvim-cmp m.nnoremap("gd", vim.lsp.buf.definition(), "LSP: goto definition") m.nnoremap("gD", vim.lsp.buf.declaration(), "LSP: goto declaration") m.nnoremap("gi", vim.lsp.buf.implementation(), "LSP: list implementation") m.nnoremap("gr", function() vim.lsp.buf.references() end, "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") -- rmagatti/goto-preview m.nnoremap("gpd", function() require('goto-preview').goto_preview_definition() end, "LSP: preview definition") m.nnoremap("gpy", function() require('goto-preview').goto_preview_type_definition() end, "LSP: preview type definition") m.nnoremap("gpi", function() require('goto-preview').goto_preview_implementation() end, "LSP: list preview implementation") m.nnoremap("gpD", function() require('goto-preview').goto_preview_declaration() end, "LSP: preview declaration") m.nnoremap("gpr", function() require('goto-preview').goto_preview_references() end, "LSP: list preview references") m.nnoremap("gpc", function() require('goto-preview').close_all_win() end, "LSP: close all preview windows") -- filipdutescu/renamer.nvim m.nnoremap("", function() require("renamer").rename() end, "LSP: rename") -- nvim-telescope/telescope.nvim m.nnoremap("", ':Telescope find_files', "Telescope: find files") -- kamykn/spelunker.vim m.nnoremap("", ':call spelunker#toggle()', "Spelling: toggle spell check") -- kevinhwang91/nvim-ufo m.nnoremap("K", function() local winid = require('ufo').peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end, "LSP: peek folded section") -- kevinhwang91/nvim-hlslens m.nnoremap("n", [[execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()]], 'silent', "Search: search forward") m.nnoremap("N", [[execute('normal! ' . v:count1 . 'N')lua require('hlslens').start()]], 'silent', "Search: search backwards") -- sindrets/winshift.nvim m.nnoremap("m", ":WinShift", "Navigation: enter window shift mode")