local map = function(mode, keys, func, options) if not options then options = {} end if options.desc then options.desc = "[" .. keys .. "] " .. options.desc end vim.keymap.set(mode, keys, func, options) end -- Thank you ThePrimeagen --------------- -- Move when highlighted map("v", "J", ":m '>+1gv=gv") map("v", "K", ":m '<-2gv=gv") -- Make cursor stay in place when using J map("n", "J", "mzJ`z") -- Make cursor stay in the middle when jumping -- with ctrl+d and ctrl+u map("n", "", "zz") map("n", "", "zz") -- Just to be sure, whatever map("n", "", "") -- Don't press Q map("n", "Q", "") -- Delete to the void map("n", "d", '"_d') map("v", "d", '"_d') -- Replace current word in entire file map("n", "s", [[:%s/\<\>//gI]]) -- Turn file into a Linux executable map("n", "x", "!chmod +x %", { silent = true }) -- Harpoon ------------------------------ local harpoon = require("harpoon") harpoon:setup() map("n", "w", function() harpoon:list():append() end, { desc = "[Harpoon] Append to list" }) map("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, { desc = "[Harpoon] Open quick menu" }) map("n", "1", function() harpoon:list():select(1) end, { desc = "[Harpoon] Jump to item 1" }) map("n", "2", function() harpoon:list():select(2) end, { desc = "[Harpoon] Jump to item 2" }) map("n", "3", function() harpoon:list():select(3) end, { desc = "[Harpoon] Jump to item 3" }) map("n", "4", function() harpoon:list():select(4) end, { desc = "[Harpoon] Jump to item 4" }) map("n", "", function() harpoon:list():prev() end, { desc = "[Harpoon] Jump to previous item" }) map("n", "", function() harpoon:list():next() end, { desc = "[Harpoon] Jump to next item" }) -- -------------------------------------- map("n", "w\\", ":vsplit", { desc = "Splits the window vertically" }) map("n", "w/", ":split", { desc = "Splits the window horizontally" }) map("n", "e", ":Ex", { desc = "Explorer" }) map("n", "s=", "z=", { desc = "Suggest spelling correction" }) map("n", "st", function() if vim.o.spell then vim.o.spell = false else vim.o.spell = true end end, { desc = "Toggle spelling correction" }) map("n", "ee", vim.diagnostic.open_float, { desc = "Open diagnostic" }) map({ "n", "v" }, "", "", { silent = true }) -- Remap for dealing with word wrap map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -- Barbar ------------------------------- map("n", "wc", "BufferClose", { desc = "Buffer close", noremap = true, silent = true }) map("n", "wA", "BufferCloseAllButCurrent", { desc = "Buffer close all", noremap = true, silent = true })