115 lines
3.4 KiB
Lua
115 lines
3.4 KiB
Lua
-- Shorten function name
|
|
local keymap = vim.keymap.set
|
|
-- Silent keymap option
|
|
local opts = { silent = true }
|
|
|
|
--Remap space as leader key
|
|
keymap("", "<Space>", "<Nop>", opts)
|
|
vim.g.mapleader = " "
|
|
|
|
-- Modes
|
|
-- normal_mode = "n",
|
|
-- insert_mode = "i",
|
|
-- visual_mode = "v",
|
|
-- visual_block_mode = "x",
|
|
-- term_mode = "t",
|
|
-- command_mode = "c",
|
|
|
|
-- Normal --
|
|
-- Resize with arrows
|
|
|
|
-- show the undo tree
|
|
keymap("n", "<leader>u", vim.cmd.UndotreeToggle)
|
|
|
|
-- Open the file explorer
|
|
keymap("n", "<S-f>", ":Telescope file_browser path=%:p:h select_buffer=true<CR>", opts)
|
|
|
|
-- Navigate buffers
|
|
keymap("n", "<S-l>", ":bnext<CR>", opts)
|
|
keymap("n", "<S-h>", ":bprevious<CR>", opts)
|
|
|
|
-- Clear highlights
|
|
keymap("n", "<leader>h", "<cmd>nohlsearch<CR>", opts)
|
|
|
|
-- Close buffers
|
|
keymap("n", "<S-q>", "<cmd>Bdelete!<CR>", opts)
|
|
|
|
-- moving around lines
|
|
keymap("n", "<A-Down>", ":m +1<CR>", opts)
|
|
keymap("n", "<A-Up>", ":m -2<CR>", opts)
|
|
|
|
-- moving to next and previous paragraphs
|
|
keymap("n", "<C-Down>", "}", opts)
|
|
keymap("n", "<C-Up>", "{", opts)
|
|
|
|
-- moving to the next and previous word, seperated by whitespace
|
|
keymap("n", "<C-Right>", "E", opts)
|
|
keymap("n", "<C-Left>", "B", opts)
|
|
|
|
-- moving to the beginning or end of the current word
|
|
keymap("n", "<S-Right>", "e", opts)
|
|
keymap("n", "<S-Left>", "b", opts)
|
|
|
|
-- Better paste
|
|
keymap("n", "<C-S-v>", "p", opts)
|
|
keymap("i", "<c-s-v>", "<ESC>:normal p<CR>a", opts)
|
|
|
|
-- saving
|
|
keymap("n", "<C-s>", ":w!<CR>", opts)
|
|
|
|
-- Insert --
|
|
-- Press jk fast to enter
|
|
keymap("i", "jk", "<ESC>", opts)
|
|
|
|
-- moving to next and previous paragraphs
|
|
keymap("i", "<C-Down>", "<C-o>}", opts)
|
|
keymap("i", "<C-Up>", "<C-o>{", opts)
|
|
|
|
-- moving to the next and previous word, seperated by whitespace
|
|
keymap("i", "<C-Right>", "<C-o>E", opts)
|
|
keymap("i", "<C-Left>", "<C-o>B", opts)
|
|
|
|
-- deleting back a word
|
|
keymap("i", "<C-BS>", "<c-w>", opts)
|
|
|
|
-- Visual --
|
|
-- Stay in indent mode
|
|
keymap("v", "<", "<gv", opts)
|
|
keymap("v", ">", ">gv", opts)
|
|
|
|
-- moving around visual blocks
|
|
keymap("v", "<A-Down>", ":m '>+1<CR>gv=gv", opts)
|
|
keymap("v", "<A-Up>", ":m .-2<CR>gv=gv", opts)
|
|
|
|
-- Plugins --
|
|
|
|
-- NvimTree
|
|
keymap("n", "<leader>e", ":NvimTreeToggle<CR>", opts)
|
|
|
|
-- Telescope
|
|
keymap("n", "<leader>ff", ":Telescope find_files<CR>", opts)
|
|
keymap("n", "<leader>ft", ":Telescope live_grep<CR>", opts)
|
|
keymap("n", "<leader>fp", ":Telescope projects<CR>", opts)
|
|
keymap("n", "<leader>fb", ":Telescope buffers<CR>", opts)
|
|
|
|
-- Git
|
|
keymap("n", "<leader>gg", "<cmd>lua _LAZYGIT_TOGGLE()<CR>", opts)
|
|
|
|
-- Comment
|
|
keymap("n", "<C-c>", "<cmd>lua require('Comment.api').toggle.linewise.current()<CR>", opts)
|
|
keymap("x", "<C-c>", ":lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>", opts)
|
|
|
|
-- DAP
|
|
keymap("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts)
|
|
keymap("n", "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", opts)
|
|
keymap("n", "<leader>di", "<cmd>lua require'dap'.step_into()<cr>", opts)
|
|
keymap("n", "<leader>do", "<cmd>lua require'dap'.step_over()<cr>", opts)
|
|
keymap("n", "<leader>dO", "<cmd>lua require'dap'.step_out()<cr>", opts)
|
|
keymap("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", opts)
|
|
keymap("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>", opts)
|
|
keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts)
|
|
keymap("n", "<leader>dt", "<cmd>lua require'dap'.terminate()<cr>", opts)
|
|
|
|
-- Lsp
|
|
keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
|