29 lines
999 B
Lua

local map = function(mode, lhs, rhs, info)
vim.keymap.set(mode, lhs, rhs, { desc = info })
end
-- Basics
map("n", ";", ":", "Command mode")
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
map("n", "U", "<cmd>redo<cr>", "Redo")
map("n", "<C-n>", "<cmd>enew<cr>", "New File")
map("n", "<C-r>", ":%s/<C-R><C-W>//g<Left><Left>", "Replace word under cursor")
map("n", "<C-q>", "<cmd>qa<cr>", "Quit all")
map({"n", "v"}, "<C-b>", "^", "Beginning of line")
map("i", "<C-b>", "<esc>^i", "Beginning of line")
map({"i", "n", "v"}, "<C-e>", "<end>", "End of line")
-- Indenting
map("v", "<", "<gv")
map("v", ">", ">gv")
-- LSP
map("n", "gd", vim.lsp.buf.definition, "Go to definition")
map("n", "gr", vim.lsp.buf.references, "Go to references")
map("n", "<leader>cf", vim.lsp.buf.format, "Format")
-- Plugins
map("n", "<leader>t", "<cmd>NvimTreeToggle<cr>", "Toggle tree")
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")