vim.api.nvim_set_keymap("n", "j", "bprev", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "k", "bnext", { noremap = true, silent = true }) vim.api.nvim_set_keymap("x", "", '"_dP', { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "/", "gcc", { noremap = false, silent = true }) vim.api.nvim_set_keymap( "v", "/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", { noremap = true, silent = true } ) -- Move to window using the hjkl keys vim.keymap.set("n", "", "h", { desc = "Go to left window", remap = true }) vim.keymap.set("n", "", "j", { desc = "Go to lower window", remap = true }) vim.keymap.set("n", "", "k", { desc = "Go to upper window", remap = true }) vim.keymap.set("n", "", "l", { desc = "Go to right window", remap = true }) -- Resize window using arrow keys vim.keymap.set("n", "", "resize +2", { desc = "Increase window height" }) vim.keymap.set("n", "", "resize -2", { desc = "Decrease window height" }) vim.keymap.set("n", "", "vertical resize -2", { desc = "Decrease window width" }) vim.keymap.set("n", "", "vertical resize +2", { desc = "Increase window width" }) -- Clear search with vim.keymap.set({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) -- Clear search, diff update and redraw -- taken from runtime/lua/_editor.lua vim.keymap.set( "n", "ur", "nohlsearchdiffupdatenormal! ", { desc = "Redraw / clear hlsearch / diff update" } ) vim.keymap.set({ "n", "x" }, "gw", "*N", { desc = "Search word under cursor" }) -- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n vim.keymap.set("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) vim.keymap.set("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) --keywordprg vim.keymap.set("n", "K", "norm! K", { desc = "Keywordprg" }) -- lazy vim.keymap.set("n", "l", "Lazy", { desc = "Lazy" }) -- new file vim.keymap.set("n", "n", "enew", { desc = "New File" }) vim.keymap.set("n", "xl", "lopen", { desc = "Location List" }) vim.keymap.set("n", "xq", "copen", { desc = "Quickfix List" }) vim.keymap.set("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) -- highlights under cursor if vim.fn.has("nvim-0.9.0") == 1 then vim.keymap.set("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) end -- Terminal vim.keymap.setpings vim.keymap.set("t", "", "", { desc = "Enter Normal Mode" }) vim.keymap.set("t", "", "wincmd h", { desc = "Go to left window" }) vim.keymap.set("t", "", "wincmd j", { desc = "Go to lower window" }) vim.keymap.set("t", "", "wincmd k", { desc = "Go to upper window" }) vim.keymap.set("t", "", "wincmd l", { desc = "Go to right window" }) vim.keymap.set("t", "", "close", { desc = "Hide Terminal" }) -- lsp vim.keymap.set("n", "gd", "lua vim.lsp.buf.definition()", { desc = "Goto Definition" }) vim.keymap.set("n", "gs", "vsplit | lua vim.lsp.buf.definition()", { desc = "Goto Definition in vertical split" }) vim.keymap.set("n", "gS", "belowright | lua vim.lsp.buf.definition()", { desc = "Goto Definition in horizontal split" }) vim.keymap.set("n", "gD", "lua vim.lsp.buf.declaration()", { desc = "Goto Declaration" }) vim.keymap.set("n", "gi", "lua vim.lsp.buf.implementation()", { desc = "Goto Implementation" }) vim.keymap.set("n", "gr", "lua vim.lsp.buf.references()", { desc = "Goto References" }) vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()", { desc = "Hover" }) vim.keymap.set("n", "ld", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) vim.keymap.set("n", "ll", "LspInfo", { desc = "Lsp Info" }) vim.keymap.set("n", "lf", vim.lsp.buf.format, { desc = "Format document" }) vim.keymap.set("n", "la", "lua vim.lsp.buf.code_action()", { desc = "Code actions" }) vim.keymap.set("n", "lr", "lua vim.lsp.buf.rename()", { desc = "Rename" }) -- colorizer vim.keymap.set("n", "cs", "ColorizerToggle", { desc = "Toggle show colors" }) -- undo tree vim.keymap.set('n', 'uu', vim.cmd.UndotreeToggle, { desc = "Toggle undo tree" }) -- harpoon vim.keymap.set("n", "hh", "lua require('harpoon.ui').toggle_quick_menu()", { desc = "Harpoon Menu" }) vim.keymap.set("n", "ha", "lua require('harpoon.mark').add_file()", { desc = "Harpoon Add File" })