38 lines
1.6 KiB
Lua

-- Map the leader to space
vim.g.mapleader = " "
-- Remove search highlight with Esc
vim.keymap.set("n", "<Esc>", ":noh<CR>")
-- Center the screen whenever I move by a large amount
--
-- Inspired by ThePrimeagen dotfiles
-- https://github.com/ThePrimeagen/init.lua/blob/e148c2cd/lua/theprimeagen/remap.lua#L9
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzz")
vim.keymap.set("n", "N", "Nzz")
vim.keymap.set("n", "}", "}zz")
vim.keymap.set("n", "{", "{zz")
vim.keymap.set("n", "%", "%zz")
-- Navigate splits
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Go to the left buffer" })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Go to the bottom buffer" })
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Go to the top buffer" })
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Go to the right buffer" })
vim.keymap.set("n", "<C-A-h>", "<C-w>H", { desc = "Move the buffer to the left" })
vim.keymap.set("n", "<C-A-j>", "<C-w>J", { desc = "Move the buffer to the bottom" })
vim.keymap.set("n", "<C-A-k>", "<C-w>K", { desc = "Move the buffer to the top" })
vim.keymap.set("n", "<C-A-l>", "<C-w>L", { desc = "Move the buffer to the right" })
-- Move the selection up and down
-- https://github.com/ThePrimeagen/init.lua/blob/e148c2cd/lua/theprimeagen/remap.lua#L5
vim.keymap.set("v", "J", [[:m ">+1<CR>gv=gv]])
vim.keymap.set("v", "K", [[:m "<-2<CR>gv=gv]])
-- Don"t move the cursor when I do a `J`
-- https://github.com/ThePrimeagen/init.lua/blob/e148c2cd/lua/theprimeagen/remap.lua#L8
vim.keymap.set("n", "J", "mzJ`z")