|
|
|
@ -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("<leader>g", "Git")
|
|
|
|
|
m.nname("<leader>gd", "Git: diff")
|
|
|
|
|
m.nname("<leader>s", "Substitute")
|
|
|
|
|
m.nname("<leader>t", "Terminal")
|
|
|
|
|
|
|
|
|
|
-- unmap unwanted commands
|
|
|
|
|
m.nnoremap("Zt", '<NOP>')
|
|
|
|
|
m.nnoremap("ZT", '<NOP>')
|
|
|
|
|
m.nnoremap("<Space>", '<NOP>')
|
|
|
|
|
m.inoremap("<F1>", '<NOP>')
|
|
|
|
|
m.nnoremap("<F1>", '<NOP>')
|
|
|
|
@ -27,67 +39,57 @@ m.inoremap("<F11>", '<NOP>')
|
|
|
|
|
m.nnoremap("<F11>", '<NOP>')
|
|
|
|
|
m.inoremap("<F12>", '<NOP>')
|
|
|
|
|
m.nnoremap("<F12>", '<NOP>')
|
|
|
|
|
m.nnoremap("ZT", '<NOP>')
|
|
|
|
|
m.nnoremap("Zt", '<NOP>')
|
|
|
|
|
|
|
|
|
|
-- shortcut for split navigation
|
|
|
|
|
m.nnoremap("<C-h>", '<C-w>h', 'splits: go to left split')
|
|
|
|
|
m.nnoremap("<C-j>", '<C-w>j', 'splits: go to lower split')
|
|
|
|
|
m.nnoremap("<C-k>", '<C-w>k', 'splits: go to upper split')
|
|
|
|
|
m.nnoremap("<C-l>", '<C-w>l', 'splits: go to right split')
|
|
|
|
|
m.nnoremap("<C-h>", '<C-w>h', 'Navigation: go to left split')
|
|
|
|
|
m.nnoremap("<C-j>", '<C-w>j', 'Navigation: go to lower split')
|
|
|
|
|
m.nnoremap("<C-k>", '<C-w>k', 'Navigation: go to upper split')
|
|
|
|
|
m.nnoremap("<C-l>", '<C-w>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("<leader>c", ':w! | !compiler <c-r>%<CR>', 'Compile current file')
|
|
|
|
|
m.nnoremap("<leader>c", ':w! | !compiler <c-r>%<CR>', '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" <bar> edit!', 'Write file over with sudo')
|
|
|
|
|
m.cnoremap("w!!", 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!', 'Write: overwrite file over with sudo')
|
|
|
|
|
|
|
|
|
|
-- easy substitution for whole file and line, visual mode
|
|
|
|
|
m.nname("<leader>s", "Substitute")
|
|
|
|
|
m.nnoremap("<leader>ss", ':%s/\\<<C-r><C-w>\\>//g<Left><Left>', 'Substitute: word under cursor')
|
|
|
|
|
m.nnoremap("<leader>sa", ':%s//g<Left><Left>', '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("<leader>ss", ':%s/\\<<C-r><C-w>\\>//g<Left><Left>', 'Substitute: word under cursor')
|
|
|
|
|
|
|
|
|
|
-- stevearc/aerial.nvim
|
|
|
|
|
m.nmap('<F3>', ':AerialToggle!<CR>', 'Aerial: Open side window')
|
|
|
|
|
m.nmap('<F3>', ':AerialToggle!<CR>', 'CTags: toggle')
|
|
|
|
|
|
|
|
|
|
-- nvim-tree/nvim-tree.lua
|
|
|
|
|
m.nmap("<F2>", ':NvimTreeToggle toggle<CR>', 'NvimTree: toggle')
|
|
|
|
|
m.nmap("<F2>", ':NvimTreeToggle toggle<CR>', 'File tree: toggle')
|
|
|
|
|
|
|
|
|
|
-- numtostr/fterm.nvim
|
|
|
|
|
m.nname("<leader>t", "FTerm")
|
|
|
|
|
m.nnoremap("<leader>tt", require("FTerm").toggle, 'Terminal: toggle')
|
|
|
|
|
m.tnoremap("<leader>tt", require("FTerm").toggle, 'Terminal: toggle')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- sindrets/diffview.nvim
|
|
|
|
|
m.nname("<leader>g", "Git")
|
|
|
|
|
m.nnoremap("<leader>tt", require("FTerm").toggle, 'Terminal: open')
|
|
|
|
|
m.tnoremap("<leader>tt", require("FTerm").toggle, 'Terminal: open')
|
|
|
|
|
local lazygit = require("FTerm"):new({
|
|
|
|
|
cmd = 'lazygit',
|
|
|
|
|
})
|
|
|
|
|
m.nnoremap("<leader>tg", function() lazygit:toggle() end, 'Lazygit: toggle')
|
|
|
|
|
m.tnoremap("<leader>tg", function() lazygit:toggle() end, 'Lazygit: toggle')
|
|
|
|
|
m.nnoremap("<leader>gt", function() lazygit:toggle() end, 'Git: open lazygit')
|
|
|
|
|
m.tnoremap("<leader>gt", function() lazygit:toggle() end, 'Git: open lazygit')
|
|
|
|
|
m.nnoremap("<leader>tg", function() lazygit:toggle() end, 'Terminal: open lazygit')
|
|
|
|
|
m.tnoremap("<leader>tg", function() lazygit:toggle() end, 'Terminal: open lazygit')
|
|
|
|
|
|
|
|
|
|
m.nname("<leader>gd", "Git Diff")
|
|
|
|
|
m.nmap("<leader>gdo", ":DiffviewOpen<CR>", "Git Diff: open")
|
|
|
|
|
m.nmap("<leader>gdc", ":DiffviewClose<CR>", "Git Diff: close")
|
|
|
|
|
-- sindrets/diffview.nvim
|
|
|
|
|
m.nmap("<leader>gdo", ":DiffviewOpen<CR>", "Git: open diff")
|
|
|
|
|
m.nmap("<leader>gdc", ":DiffviewClose<CR>", "Git: close diff")
|
|
|
|
|
|
|
|
|
|
-- folke/trouble.nvim
|
|
|
|
|
m.nmap("<leader>x", ":TroubleToggle<CR>", "Trouble: toggle")
|
|
|
|
|
m.nmap("<leader>x", ":TroubleToggle<CR>", "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("<F8>", function() require("conform").format({ async = true, lsp_fallback = true }) end, "LSP: format")
|
|
|
|
|
|
|
|
|
@ -98,7 +100,7 @@ m.nnoremap("<F5>", require("renamer").rename, "LSP: rename")
|
|
|
|
|
m.nnoremap("<F4>", ':Telescope find_files<CR>', "Telescope: find files")
|
|
|
|
|
|
|
|
|
|
-- kamykn/spelunker.vim
|
|
|
|
|
m.nnoremap("<F6>", ':call spelunker#toggle()<CR>', "Spelunker: toggle")
|
|
|
|
|
m.nnoremap("<F6>", ':call spelunker#toggle()<CR>', "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", [[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]],
|
|
|
|
|
'silent', "HLSens: search forward")
|
|
|
|
|
'silent', "Search: search forward")
|
|
|
|
|
m.nnoremap("N", [[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]],
|
|
|
|
|
'silent', "HLSens: search backwards")
|
|
|
|
|
'silent', "Search: search backwards")
|
|
|
|
|