local map, lz = core.misc.map, core.misc.lz --- feed keys as userinput ---@param keys string keys local function feedkeys(keys) vim.api.nvim_feedkeys( vim.api.nvim_replace_termcodes(keys, true, false, true), "n", true) end -- vim binds vim.g.mapleader = " " -- set leader key map("x", "p", [["_dP]], { desc = "Greatest remap of all time." }) map("n", "", "noh:ec", { desc = "Clear search." }) map("n", "a", lz "e #zz", { desc = "swap to alt file" }) -- the cursor STAYS IN THE MIDDLE map("n", "", lz "mzJ`zdelm z") -- when combining lines map("n", "n", lz "nzzzv") -- when searching map("n", "N", lz "Nzzzv") map("n", "", lz "zz") -- half page jumping map("n", "", lz "zz") map("n", "", lz "zz") -- jump history map("n", "", lz "zz") -- trigger completion menu -- (stolen from https://gist.github.com/MariaSolOs/2e44a86f569323c478e5a078d0cf98cc) map("i", "", function() -- if the completion menu is already visible just go to the next item if vim.fn.pumvisible() ~= 0 then feedkeys("") else if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then vim.lsp.completion.get() else if vim.bo.omnifunc == "" then feedkeys("") else feedkeys("") end end end end, { desc = "Trigger/select next completion" }) map("i", "", "", { desc = "Trigger spell completion" }) map("n", "", lz "se spellease nospell", { desc = "Trigger spell completion" }) -- quickfix map("n", "", "cnext", { desc = "qf next" }) map("n", "", "cprev", { desc = "qf prev" }) map("n", "", "cclose", { desc = "qf close" }) map("n", "", "cope", { desc = "qf open" }) -- man pages map("n", "", "Man") -- okay this is gonna sound crazy, but I like emacs binds for editing when I'm -- stuck without modal editing like in command mode. map("c", "", function() feedkeys("") end) map("c", "", function() feedkeys("") end) map("c", "", function() feedkeys("") end) -- execute line/block map("n", "x", ":.lua") map("x", "x", ":lua")