From 99bf63b2cefd5300f117ac7093bcf51ffc77bb04 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sat, 17 Sep 2022 16:12:15 -0500 Subject: [PATCH] refactor(nvim): improve core mappings --- .../primary/config/lua/core/mappings.lua | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/dots/.nvim-environments/primary/config/lua/core/mappings.lua b/dots/.nvim-environments/primary/config/lua/core/mappings.lua index 088112da..7f9f5b97 100755 --- a/dots/.nvim-environments/primary/config/lua/core/mappings.lua +++ b/dots/.nvim-environments/primary/config/lua/core/mappings.lua @@ -5,22 +5,26 @@ M.setup = function() vim.g.mapleader = " " -- Get rid of highlight after search - vim.keymap.set("n", "", ":noh") + vim.keymap.set("n", "", function() + vim.api.nvim_command("noh") + end, { silent = true, desc = "Remove Highlighted Searches" }) -- Spell Checking - vim.keymap.set("n", "st", ":set spell!") + vim.keymap.set("n", "st", function() + vim.opt.spell = not vim.opt.spell:get() + end, { silent = true, desc = "Toggle Spell" }) -- Better split movement - vim.keymap.set("n", "", "l") - vim.keymap.set("n", "", "h") - vim.keymap.set("n", "", "k") - vim.keymap.set("n", "", "j") + vim.keymap.set("n", "", "l", { silent = true }) + vim.keymap.set("n", "", "h", { silent = true }) + vim.keymap.set("n", "", "k", { silent = true }) + vim.keymap.set("n", "", "j", { silent = true }) -- Better split closing - vim.keymap.set("n", "", "c") + vim.keymap.set("n", "", "c", { silent = true }) -- Set current focused file as cwd - vim.keymap.set("n", "cd", ":cd %:p:h") + vim.keymap.set("n", "cd", ":cd %:p:h", { silent = true, desc = "Change CWD to Current File" }) -- Toggle showing diagnostics local diagnostics_active = true @@ -31,7 +35,7 @@ M.setup = function() else vim.diagnostic.disable() end - end, { desc = "Toggle Diagnostics" }) + end, { silent = true, desc = "Toggle Diagnostics" }) -- Toggle showing command bar vim.keymap.set("n", "cl", function() @@ -41,18 +45,18 @@ M.setup = function() else vim.opt.cmdheight = 1 end - end, { desc = "Toggle Cmdline" }) + end, { silent = true, desc = "Toggle Cmdline" }) -- Toggle relativenumber vim.keymap.set("n", "sn", function() vim.opt.relativenumber = not vim.opt.relativenumber:get() - end, { desc = "Toggle Relativenumber" }) + end, { silent = true, desc = "Toggle Relativenumber" }) -- Sudo Write - vim.keymap.set("c", "w!!", "w !sudo tee > /dev/null %") + vim.keymap.set("c", "w!!", "w !sudo tee > /dev/null %", { silent = true, desc = "Write as Sudo" }) -- Terminal mappings - vim.keymap.set("t", [[]], [[]]) + vim.keymap.set("t", [[]], [[]], { silent = true }) end return M