local function map(modes, lhs, rhs, opts) -- NOTE: Use ``, ``, `` casing (instead of ``, ``, -- ``) to match the `lhs` of keymap info. Otherwise it will say that -- Otherwise it will just say that -- mapping doesn't exist when in fact it does. if type(modes) == "string" then modes = { modes } end for _, mode in ipairs(modes) do opts = vim.tbl_deep_extend("force", { silent = true }, opts or {}) vim.keymap.set(mode, lhs, rhs, opts) end end local function unmap(mode, key) vim.keymap.del(mode, key, {}) end local Util = require("lazyvim.util") -- Unbind stuff relating to terminal unmap("t", "") -- Unbind stuff relating to splitting windows unmap("n", "ww") unmap("n", "w-") unmap("n", "w|") unmap("n", "wd") unmap("n", "bb") -- Restore "H" & "L" from neovim unmap("n", "H") unmap("n", "L") -- Unbind moving lines with ALT in INSERT/VISUAL mode unmap({ "i", "v" }, "") unmap({ "i", "v" }, "") -- Unbind Telescope stuff unmap("n", "fn") -- Idk what this does "Keywordprg" unmap("n", "K") -- Remove the default quit unmap("n", "qq") -- I can just type :Lazy unmap("n", "l") -- Rebind format from cf to lf unmap({ "n", "v" }, "cf") map({ "n", "v" }, "lf", function() Util.format({ force = true }) end, { desc = "Format" }) -- Easy repeat of last macro map({ "n" }, "Q", '@@', { desc = "Repeat last macro" }) -- Copy/paste with system clipboard map({ "n", "x" }, "gy", '"+y', { desc = "Copy to system clipboard" }) map("n", "gp", '"+p', { desc = "Paste from system clipboard" }) -- - Paste in Visual with `P` to not copy selected text (`:h v_P`) map("x", "gp", '"+P', { desc = "Paste from system clipboard" }) -- I use gl for this unmap("n", "cd") map("n", "gl", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) -- Configure diagnostics with borders local diagnostic_goto = function(next, severity) local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev severity = severity and vim.diagnostic.severity[severity] or nil return function() go({ severity = severity, float = { border = "rounded" } }) end end map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" }) map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" }) map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" }) map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" }) map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" }) map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) map("n", "0", "0^", { desc = "which_key_ignore" }) map("n", "", "o", { desc = "which_key_ignore" }) map("n", "", "o", { desc = "which_key_ignore" }) map("n", "", "zz", { desc = "which_key_ignore" }) map("n", "", "zz", { desc = "which_key_ignore" }) map("n", "w", "w", { desc = "Write", nowait = true }) map("n", "Q", "qa", { desc = "Quit All" }) map("n", "q", "q", { desc = "Quit", nowait = true }) map("n", "", "h", { desc = "Go to left window", remap = true }) map("n", "", "j", { desc = "Go to lower window", remap = true }) map("n", "", "k", { desc = "Go to upper window", remap = true }) map("n", "", "l", { desc = "Go to right window", remap = true })