local function map(mode, shortcut, command) vim.api.nvim_set_keymap(mode, shortcut, command, {noremap = true, silent = true}) end local function nmap(shortcut, command) map("n", shortcut, command) end local function vmap(shortcut, command) map("v", shortcut, command) end -- Quickly save/quit vim nmap("w", ":w") nmap("q", ":q") -- Move line under the cursor up and down nmap("", ":m .-2==") nmap("", ":m .+1==") vmap("K", ":m '<-2gv=gv") vmap("J", ":m '>+1gv=gv") -- Remove search highlighting nmap("nh", ":nohl") -- Escape from terminal map("t", "", "") -- Open splits nmap("sv", ":vs") nmap("sh", ":sp") -- Move focus between splits nmap("h", "h") nmap("j", "j") nmap("k", "k") nmap("l", "l") -- Resize splits nmap("", ":resize -2") nmap("", ":resize +2") nmap("", ":vert resize -10") nmap("", ":vert resize +10") -- File Tree nmap("b", ":NvimTreeToggle") -- Telescope nmap("p", ":Telescope") nmap("f", ":Telescope find_files") -- LSP nmap("K", ":lua vim.lsp.buf.hover()") nmap("gd", ":lua vim.lsp.buf.definition()") nmap("gr", ":lua vim.lsp.buf.references()") nmap(".", ":lua vim.lsp.buf.code_action()") nmap("", ":lua vim.lsp.buf.rename()") -- Tabs nmap("1", ":BufferGoto 1") nmap("2", ":BufferGoto 2") nmap("3", ":BufferGoto 3") nmap("4", ":BufferGoto 4") nmap("5", ":BufferGoto 5") nmap("6", ":BufferGoto 6") nmap("7", ":BufferGoto 7") nmap("8", ":BufferGoto 8") nmap("9", ":BufferGoto 9") nmap("e", ":BufferClose") -- Git nmap("gg", ":G | :resize -10") nmap("t", ":ToggleTerminal")