30 lines
1.1 KiB
Lua

local map = function(mode, lhs, rhs, info)
vim.keymap.set(mode, lhs, rhs, { desc = info })
end
-- Basics
map("n", "<C-n>", "<cmd>enew<cr>", "New File")
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
map("n", "<C-q>", "<cmd>qa<cr>", "Quit all")
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
-- 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")
-- Toggle comment
map("n", "<C-_>", "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", "Toggle comment")
map("v", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", "Toggle comment")
-- Normal mode
map("n", "<C-b>", "<cmd>NvimTreeToggle<cr>", "Toggle tree")
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")
map("n", "<leader>f", "<cmd>Telescope find_files<cr>", "Find files")
map("n", "<leader>r", "<cmd>Telescope oldfiles<cr>", "Recent files")
map({ "n", "t" }, "<A-i>", "<cmd>lua require('nvterm.terminal').toggle('float')<cr>", "Toggle terminal")