viminal2/lua/keymaps.lua

62 lines
2.2 KiB
Lua
Raw Normal View History

2024-10-09 17:13:16 -07:00
-- Non-exhaustive collection of keymaps. I've decided it's more sane to place
-- plugin specific maps in their respective setup scripts
2024-10-10 00:21:39 -07:00
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>", "<nop>")
vim.keymap.set("t", "<C-Esc>", "<C-\\><C-n>")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
2024-10-10 00:48:10 -07:00
vim.keymap.set("n", "<leader>mr", function()
2024-10-10 00:21:39 -07:00
vim.cmd.CellularAutomaton("make_it_rain")
end)
2024-10-10 00:48:10 -07:00
vim.keymap.set("n", "<leader>bruh", function()
2024-10-10 00:21:39 -07:00
vim.cmd.CellularAutomaton("game_of_life")
end)
-- when searching, also center screen and reopen folds
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- The greatest remap of all time -- the primeagen
2024-10-10 00:48:10 -07:00
vim.keymap.set({ "n", "v" }, "<leader>d", '"_d', { desc = "same as `d` but send to black hole register" })
vim.keymap.set({ "n", "v" }, "<leader>D", '"_D', { desc = "same as `D` but send to black hole register" })
2024-10-10 00:21:39 -07:00
-- The real greatest remap(s) of all time -- me
2024-10-10 00:48:10 -07:00
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "yank to clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>Y", '"+Y', { desc = "yank rest of line to clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p', { desc = "put after cursor from clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>P", '"+P', { desc = "put before cursor from clipboard" })
2024-10-10 00:21:39 -07:00
2024-10-10 00:48:10 -07:00
vim.keymap.set("n", "<leader>gg", function()
2024-10-10 00:21:39 -07:00
vim.cmd.Neogit()
end, { desc = "Open neogit" })
2024-10-10 00:48:10 -07:00
vim.keymap.set("n", "<leader>gc", function()
2024-10-10 00:21:39 -07:00
vim.cmd.Neogit("kind=floating commit")
end, { desc = "Open neogit commit menu" })
2024-10-10 00:48:10 -07:00
vim.keymap.set("n", "<leader>u", function()
2024-10-10 00:21:39 -07:00
vim.cmd.UndotreeToggle()
2024-10-10 00:48:10 -07:00
end, { desc = "Toggle undotree" })
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
require("conform").format({ async = true })
end)
vim.keymap.set({ "n", "v" }, "<leader>ctf", function()
if vim.g.disable_autoformat then
vim.g.disable_autoformat = false
else
vim.g.disable_autoformat = true
end
end, { desc = "Disable autoformat on save globally" })
vim.keymap.set({ "n", "v" }, "<leader>cbf", function()
if vim.b[0].disable_autoformat then
vim.b[0].disable_autoformat = false
else
vim.b[0].disable_autoformat = true
end
end, { desc = "Disable autoformat on save buffer" })
2024-10-10 00:59:42 -07:00
vim.keymap.set("i", "<Tab>", require("scripts.intellitab").indent)