nvim/lua/eddie/remaps.lua

96 lines
3.9 KiB
Lua
Raw Permalink Normal View History

-- Open Ex as buffer
2024-01-31 10:56:31 +00:00
-- vim.keymap.set("n", "<leader>pv", vim.cmd.Ex, { desc = "Open Ex" })
vim.keymap.set("n", "<leader>pv", ":NvimTreeToggle<CR>", { desc = "Open Ex" })
-- Exit insert mode without hitting Esc
2023-09-06 08:52:13 +00:00
vim.keymap.set("i", "jj", "<Esc>", { desc = "Esc" })
-- Make Y behave like C or D
vim.keymap.set("n", "Y", "y$")
-- Keep window centered when going up/down
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- Paste without overwriting register
vim.keymap.set("v", "p", '"_dP')
-- Copy text to " register
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>y", "\"+y", { desc = "Yank into \" register" })
vim.keymap.set("v", "<leader>y", "\"+y", { desc = "Yank into \" register" })
vim.keymap.set("n", "<leader>Y", "\"+Y", { desc = "Yank into \" register" })
-- Delete text to " register
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>d", "\"_d", { desc = "Delete into \" register" })
vim.keymap.set("v", "<leader>d", "\"_d", { desc = "Delete into \" register" })
-- Get out Q
vim.keymap.set("n", "Q", "<nop>")
-- close buffer
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>q", "<cmd>bd<CR>", { desc = "Close Buffer" })
-- Close buffer without closing split
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>w", "<cmd>bp|bd #<CR>", { desc = "Close Buffer; Retain Split" })
-- Navigate between quickfix items
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>h", "<cmd>cnext<CR>zz", { desc = "Forward qfixlist" })
vim.keymap.set("n", "<leader>;", "<cmd>cprev<CR>zz", { desc = "Backward qfixlist" })
-- Navigate between location list items
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Forward location list" })
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Backward location list" })
-- Replace word under cursor across entire buffer
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = "Replace word under cursor" })
-- Make current file executable
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Make current file executable" })
-- Jump to plugin management file
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>vpp", "<cmd>e ~/.config/nvim/lua/exosyphon/lazy.lua<CR>", { desc = "Jump to lazy.lua" })
-- Git revert at current cursor location
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>U", "<cmd>GitGutterUndoHunk<CR>", { desc = "Revert Git Hunk" })
-- Copy file paths
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<leader>cf", "<cmd>let @+ = expand(\"%\")<CR>", { desc = "Copy File Name" })
vim.keymap.set("n", "<leader>cp", "<cmd>let @+ = expand(\"%:p\")<CR>", { desc = "Copy File Path" })
2024-09-25 16:19:14 +00:00
vim.keymap.set("n", "<leader>so", function()
vim.cmd("so")
2023-09-06 08:52:13 +00:00
end, { desc = "Source current file" })
-- Resize with arrows
2023-09-06 08:52:13 +00:00
vim.keymap.set("n", "<C-S-Down>", ":resize +2<CR>", { desc = "Resize Horizontal Split Down" })
vim.keymap.set("n", "<C-S-Up>", ":resize -2<CR>", { desc = "Resize Horizontal Split Up" })
vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Resize Vertical Split Down" })
vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Resize Vertical Split Up" })
2024-09-25 16:19:14 +00:00
-- Open compiler
vim.api.nvim_set_keymap('n', '<leader><leader>', "<cmd>CompilerOpen<cr>", { noremap = true, silent = true })
-- Redo last selected option
vim.api.nvim_set_keymap('n', '<leader><leader><leader>',
"<cmd>CompilerStop<cr>" -- (Optional, to dispose all tasks before redo)
.. "<cmd>CompilerRedo<cr>",
{ noremap = true, silent = true })
-- Toggle compiler results
vim.api.nvim_set_keymap('n', '<leader><leader>t', "<cmd>CompilerToggleResults<cr>", { noremap = true, silent = true })
-- Visual --
-- Stay in indent mode
vim.keymap.set("v", "<", "<gv")
vim.keymap.set("v", ">", ">gv")
-- Move block
2023-09-06 08:52:13 +00:00
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move Block Down" })
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move Block Up" })
-- Search for highlighted text in buffer
2023-09-06 08:52:13 +00:00
vim.keymap.set("v", "//", 'y/<C-R>"<CR>', { desc = "Search for highlighted text" })