-- set leader key to space vim.g.mapleader = " " local keymap = vim.keymap -- for conciseness --------------------- -- General Keymaps --------------------- -- use jk to exit insert mode keymap.set("i", "jk", "") -- clear search highlights keymap.set("n", "nh", ":nohl") -- delete single character without copying into register keymap.set("n", "x", '"_x') -- increment/decrement numbers keymap.set("n", "+", "") -- increment keymap.set("n", "-", "") -- decrement -- window management keymap.set("n", "dv", "v") -- split window vertically keymap.set("n", "dh", "s") -- split window horizontally keymap.set("n", "de", "=") -- make split windows equal width & height keymap.set("n", "dx", ":close") -- close current split window keymap.set("n", "to", ":tabnew") -- open new tab keymap.set("n", "tx", ":tabclose") -- close current tab keymap.set("n", "tn", ":tabn") -- go to next tab keymap.set("n", "tp", ":tabp") -- go to previous tab keymap.set('n', 'dd', 'yyp') -- duplicate line keymap.set('n', 'l', 'yyp') -- duplicate line keymap.set('n', 'dd', '"_dd') -- duplicate line not passing deleted line to registry keymap.set('n', '', 'ggVG') -- select-all keymap.set('n', 'J', '5j') keymap.set('n', 'K', '5k') keymap.set('n', 'rr', ':e!') -- revert file keymap.set('n', 'w', ':w') -- saves file keymap.set('n', 'q', ':q') -- quit keymap.set('n', 'zz', ':luafile %') -- re-source this -- line highlight vim.cmd[[ highlight LineHighlight ctermbg=darkgray guibg=black ]] keymap.set("n", "q", ":call matchadd('LineHighlight', '\\%'.line('.').'l')" , { silent = true }) keymap.set("n", "!", ":call clearmatches()", { silent = true }) -- bookmarks keymap.set('n', '#2', ':BookmarkNext') keymap.set('n', '', ':BookmarkToggle') ---------------------- -- PLUGINS -- vim-maximizer keymap.set("n", "sm", ":MaximizerToggle") -- toggle split window maximization -- nvim-tree keymap.set("n", "e", ":NvimTreeToggle") -- toggle file explorer -- telescope keymap.set("n", "ff", "Telescope find_files") -- find files within current working directory, respects .gitignore keymap.set("n", "fs", "Telescope live_grep") -- find string in current working directory as you type keymap.set("n", "fc", "Telescope grep_string") -- find string under cursor in current working directory keymap.set("n", "fb", "Telescope buffers") -- list open buffers in current neovim instance keymap.set("n", "fh", "Telescope help_tags") -- list available help tags keymap.set("n", "t", "Telescope vim_bookmarks current_file") keymap.set("n", "tt", "Telescope vim_bookmarks all") -- telescope git commands (not on youtube nvim video) keymap.set("n", "gc", "Telescope git_commits") -- list all git commits (use to checkout) ["gc" for git commits] keymap.set("n", "gfc", "Telescope git_bcommits") -- list git commits for current file/buffer (use to checkout) ["gfc" for git file commits] keymap.set("n", "gb", "Telescope git_branches") -- list git branches (use to checkout) ["gb" for git branch] keymap.set("n", "gs", "Telescope git_status") -- list current changes per file with diff preview ["gs" for git status] -- restart lsp server (not on youtube nvim video) keymap.set("n", "rs", ":LspRestart") -- mapping to restart lsp if necessary -- move local opts = { noremap = true, silent = false } -- Normal-mode commands keymap.set('n', '', ':MoveLine(1)', opts) keymap.set('n', '', ':MoveLine(-1)', opts) keymap.set('n', '', ':MoveHChar(-1)', opts) keymap.set('n', '', ':MoveHChar(1)', opts) -- Visual-mode commands keymap.set('v', '', ':MoveBlock(1)', opts) keymap.set('v', '', ':MoveBlock(-1)', opts) keymap.set('v', '', ':MoveHBlock(-1)', opts) keymap.set('v', '', ':MoveHBlock(1)', opts) -- Harpoon keymap.set("n", "a", function() require("harpoon.mark").add_file() end, opts) keymap.set("n", "h", function() require("harpoon.ui").toggle_quick_menu() end, opts) keymap.set("n", "1", function() require("harpoon.ui").nav_file(1) end, opts) keymap.set("n", "2", function() require("harpoon.ui").nav_file(2) end, opts) keymap.set("n", "3", function() require("harpoon.ui").nav_file(3) end, opts) keymap.set("n", "4", function() require("harpoon.ui").nav_file(4) end, opts)