local utils = require("utils") -- TODO: Use which-key for mappings local map = vim.api.nvim_set_keymap local opt_silent = { silent = true } local opt_default = { silent = true, noremap = true } map("n", "", ":set wrap!", opt_silent) map("n", "lw", ":set wrap!", opt_silent) map("n", "", ":set invnumber", opt_silent) map("n", "ln", ":set invnumber", opt_silent) map("n", "/", ":set hlsearch! hlsearch?", opt_silent) map("n", "cs", ":nohlsearch", opt_silent) map("n", "ws", ":set list!", opt_silent) -- Save and quit typos map("c", "WQ", "wq", opt_silent) map("c", "Wq", "wq", opt_silent) map("c", "W", "w", opt_silent) map("c", "Q", "q", opt_silent) map("c", "Q!", "q!", opt_silent) map("c", "Qa", "qa", opt_silent) map("c", "Qa!", "qa!", opt_silent) map("c", "QA", "qa", opt_silent) map("c", "QA!", "qa!", opt_silent) map("c", "w;", "w", opt_default) map("c", "W;", "w", opt_default) map("c", "q;", "q", opt_default) map("c", "Q;", "q", opt_default) -- Paste over map("v", "pp", "p", opt_default) map("v", "po", '"_dP', opt_default) -- Buffer nav map("n", "gb", ":bnext", { desc = "Next buffer" }) map("n", "gB", ":bprevious", { desc = "Previous buffer" }) -- Easy redo map("n", "U", ":redo", opt_default) -- Make escape easier map("i", "jk", "", opt_default) map("i", "``", "", opt_default) map("v", "``", "", opt_default) -- C-Space completion function _G.complete_space() if vim.fn.pumvisible() == 1 then return utils.t("") elseif utils.is_plugin_loaded("completion-nvim") then return utils.t("(completion_trigger)") elseif utils.is_plugin_loaded("nvim-compe") then return vim.fn["compe#complete"]() elseif utils.is_plugin_loaded("nvim-cmp") then return utils.t("(cmp_complete)") else return utils.t("") end end map("i", "", "v:lua.complete_space()", { expr = true }) -- Easily toggle spelling vim.cmd("command Spell setlocal spell! spelllang=en_us") -- Pop spelling completion for word under cursor map("n", "s", "viwas", {}) -- Build on F5 map("n", "", ":make", {})