-- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here local map = vim.keymap.set -- Custom movement keys (JKLM instead of HJKL) map({ "n", "v", "o" }, "j", "h", { desc = "Move left" }) map({ "n", "v", "o" }, "k", "v:count == 0 ? 'gj' : 'j'", { desc = "Move down", expr = true, silent = true }) map({ "n", "v" }, "", "v:count == 0 ? 'gj' : 'j'", { desc = "Move down", expr = true, silent = true }) map({ "n", "v", "o" }, "l", "v:count == 0 ? 'gk' : 'k'", { desc = "Move up", expr = true, silent = true }) map({ "n", "v" }, "", "v:count == 0 ? 'gk' : 'k'", { desc = "Move up", expr = true, silent = true }) map({ "n", "v", "o" }, "m", "l", { desc = "Move right" }) map("n", "ยง", "m", { desc = "Set a mark" }) -- Window navigation map("n", "", "h", { desc = "Go to left window" }) map("n", "", "j", { desc = "Go to lower window" }) map("n", "", "k", { desc = "Go to upper window" }) map("n", "", "l", { desc = "Go to right window" }) -- for dadbod-ui buffers, see autocmds.lua -- Move Lines map("n", "", "execute 'move .+' . v:count1==", { desc = "Move Down" }) map("n", "", "execute 'move .-' . (v:count1 + 1)==", { desc = "Move Up" }) map("i", "", "m .+1==gi", { desc = "Move Down" }) map("i", "", "m .-2==gi", { desc = "Move Up" }) map("v", "", ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = "Move Down" }) map("v", "", ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = "Move Up" }) -- Better line creation -- map("n", "o", "o", { desc = "Create line below and stay in normal mode" }) -- map("n", "O", "O", { desc = "Create line above and stay in normal mode" }) map("n", "n", "nzz") map("n", "N", "Nzz") -- Insert mode mappings map("i", "jj", "", { desc = "Exit insert mode" }) map("i", "", "ddi", { desc = "Delete line" }) map("i", "", "^i", { desc = "Beginning of line" }) map("i", "", "", { desc = "End of line" }) -- Space as command key -- map("n", "", ":", { desc = "Enter command mode" }) -- Move between buffers map("n", "", "bprevious", { desc = "Prev Buffer" }) map("n", "", "bnext", { desc = "Next Buffer" }) -- map("n", "h", function() -- require("nvchad.term").new({ pos = "sp", size = 0.4 }) -- end, { desc = "Terminal New horizontal term" }) map("t", "", "", { desc = "Terminal Escape terminal mode" }) -- Keyboard users vim.keymap.set("n", "", function() require("menu").open("default") end, {}) -- mouse users + nvimtree users! vim.keymap.set({ "n", "v" }, "", function() require("menu.utils").delete_old_menus() vim.cmd.exec('"normal! \\"') -- clicked buf local buf = vim.api.nvim_win_get_buf(vim.fn.getmousepos().winid) local options = vim.bo[buf].ft == "NvimTree" and "nvimtree" or "default" require("menu").open(options, { mouse = true }) end, {}) local nomap = vim.keymap.del nomap({ "n", "i", "v" }, "") nomap("n", "") nomap("n", "")