32 lines
1.1 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-q>", "<cmd>bd<cr>", "Delete buffer")
2023-08-21 17:19:37 +00:00
map("n", "<C-n>", "<cmd>enew<cr>", "New 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-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
2023-08-20 22:09:00 +00:00
-- Indenting
2023-08-19 17:22:56 +00:00
map("v", "<", "<gv")
map("v", ">", ">gv")
2023-08-20 22:09:00 +00:00
-- LSP
2023-08-22 14:51:35 +00:00
map("n", "gr", vim.lsp.buf.references, "Get references")
map("n", "gd", vim.lsp.buf.definition, "Get definition")
map({ "n", "i" }, "<f1>", vim.lsp.buf.hover, "Show information")
map({ "n", "i" }, "<C-f>", vim.lsp.buf.format, "Format")
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")