57 lines
1.8 KiB
Lua
Raw Normal View History

2023-08-22 14:51:35 +00:00
local function map(mode, lhs, rhs, info)
2023-08-20 22:09:00 +00:00
vim.keymap.set(mode, lhs, rhs, { desc = info })
end
2023-08-19 17:22:56 +00:00
2023-08-20 22:09:00 +00:00
-- Basics
2023-08-21 17:19:37 +00:00
map("n", ";", ":", "Command mode")
2023-08-22 14:51:35 +00:00
map("n", "qq", "<cmd>qa!<cr>", "Quit all")
map("n", "U", "<cmd>redo<cr>", "Redo")
2023-08-21 17:19:37 +00:00
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
2023-08-20 22:09:00 +00:00
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
2023-08-22 14:51:35 +00:00
map("n", "<C-l>", "^Da", "Rewrite line")
map("i", "<C-l>", "<esc>^Da", "Rewrite line")
2023-09-07 12:08:10 +00:00
map("n", "<C-a>", "ggVG", "Select all")
2023-08-21 17:19:37 +00:00
map("n", "<C-r>", ":%s/<C-R><C-W>//g<Left><Left>", "Replace word under cursor")
2023-08-22 14:51:35 +00:00
map({ "n", "v" }, "<C-b>", "^", "Beginning of line")
2023-08-21 17:19:37 +00:00
map("i", "<C-b>", "<esc>^i", "Beginning of line")
2023-08-22 14:51:35 +00:00
map({ "i", "n", "v" }, "<C-e>", "<end>", "End of line")
2023-08-19 17:22:56 +00:00
2024-01-22 14:04:33 +00:00
-- Buffer management
map("n", "<C-n>", "<cmd>enew<cr>", "New file")
map("n", "<C-q>", "<cmd>bd<cr>", "Delete buffer")
-- Copy and paste
map("v", "<C-c>", "y")
map("n", "<C-v>", '"+p')
2023-08-20 22:09:00 +00:00
-- Indenting
2023-08-19 17:22:56 +00:00
map("v", "<", "<gv")
map("v", ">", ">gv")
2024-01-22 14:04:33 +00:00
-- Shift arrow selection
map("n", "<S-Up>", "v<Up>")
map("n", "<S-Down>", "v<Down>")
map("n", "<S-Left>", "v<Left>")
map("n", "<S-Right>", "v<Right>")
map("v", "<S-Up>", "<Up>")
map("v", "<S-Down>", "<Down>")
map("v", "<S-Left>", "<Left>")
map("v", "<S-Right>", "<Right>")
map("i", "<S-Up>", "<Esc>v<Up>")
map("i", "<S-Down>", "<Esc>v<Down>")
map("i", "<S-Left>", "<Esc>v<Left>")
map("i", "<S-Right>", "<Esc>v<Right>")
2023-08-20 22:09:00 +00:00
-- LSP
2023-08-29 11:29:37 +00:00
map("n", "gr", vim.lsp.buf.references, "References")
map("n", "gd", vim.lsp.buf.definition, "Definition")
map({ "n", "i" }, "<f1>", vim.lsp.buf.hover, "Hover")
2024-01-21 16:14:47 +00:00
map({ "n", "i" }, "<f2>", vim.lsp.buf.rename, "Rename")
2023-08-22 14:51:35 +00:00
map({ "n", "i" }, "<C-f>", vim.lsp.buf.format, "Format")
2023-08-29 11:29:37 +00:00
map("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
2023-08-19 17:22:56 +00:00
2023-08-22 14:51:35 +00:00
-- Package manager
2023-08-20 22:09:00 +00:00
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")