vim.g.mapleader = " " local map = vim.keymap.set ---- Bufferline (not included xd) ---- -- Not used but maybe in the future -- map("n", "bg", "BufferLinePick") -- map("n", "bd", function() -- Snacks.bufdelete() -- end, { desc = "Delete Buffer" }) -- map("n", "x", function() -- Snacks.bufdelete() -- end, { desc = "Delete Buffer" }) -- Some QOL mappings -- -- tabpages map("n", "]", ":+tabnext", { desc = "Goes to the next tabpage" }) map("n", "[", ":-tabnext", { desc = "Goes to the previous tabpage" }) map("n", "nt", ":tabnew", { desc = "Create new tabpage" }) --------------------------------------------------------------------------- ---- Telescope find ---- map("n", "F", " Telescope resume ", { desc = "Resume las search" }) map("n", "ff", " Telescope find_files ", { desc = "Find files" }) map("n", "fa", " Telescope find_files follow=true no_ignore=true hidden=true ", { desc = "Find all" }) map("n", "fw", " Telescope live_grep ", { desc = "Live grep" }) map("n", "fb", " Telescope buffers ", { desc = "Find buffers" }) map("n", "", " Telescope current_buffer_fuzzy_find ", { desc = "Find in current buffer" }) map("n", "fh", " Telescope help_tags ", { desc = "Help page" }) map("n", "fo", " Telescope oldfiles ", { desc = "Fild old files" }) map("n", "fz", " Telescope current_buffer_fuzzy_find ", { desc = "Find in current buffer" }) map("n", "", " Telescope current_buffer_fuzzy_find ", { desc = "Find in current buffer" }) ---- Improved Movement ---- -- Move Lines map("n", "", "m .+1==", { desc = "Move Down" }) map("n", "", "m .-2==", { desc = "Move Up" }) map("i", "", "m .+1==gi", { desc = "Move Down" }) map("i", "", "m .-2==gi", { desc = "Move Up" }) map("v", "", ":m '>+1gv=gv", { desc = "Move Down" }) map("v", "", ":m '<-2gv=gv", { desc = "Move Up" }) -- Clear search with map({ "i", "n" }, "", "noh", { desc = "Escape and Clear hlsearch" }) -- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n map("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next Search Result" }) map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next Search Result" }) map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next Search Result" }) map("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev Search Result" }) map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev Search Result" }) map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev Search Result" }) ----------------------------------------------------------- -- save file map({ "i", "x", "n", "s" }, "", "w", { desc = "Save File" }) -- better indenting map("v", "<", "", ">gv") -- new file map("n", "nf", "enew", { desc = "New File" }) map("n", "", "enew", { desc = "New File" }) map("n", "[q", vim.cmd.cprev, { desc = "Previous Quickfix" }) map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" }) -- highlights under cursor map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) ---- Terminal ---- map("n", "nz", "terminal", { desc = "Open new terminal" }) -- Terminal Mappings map("t", "", "", { desc = "Enter Normal Mode" }) map("t", "", "wincmd h", { desc = "Go to Left Window" }) map("t", "", "wincmd j", { desc = "Go to Lower Window" }) map("t", "", "wincmd k", { desc = "Go to Upper Window" }) map("t", "", "wincmd l", { desc = "Go to Right Window" }) map("t", "", "close", { desc = "Hide Terminal" }) map("t", "", "close", { desc = "which_key_ignore" }) --------------------------------------------------------------------------- ---- Windows ---- map("n", "ww", "p", { desc = "Other Window", remap = true }) map("n", "wd", "c", { desc = "Delete Window", remap = true }) map("n", "w-", "s", { desc = "Split Window Below", remap = true }) map("n", "w|", "v", { desc = "Split Window Right", remap = true }) map("n", "-", "s", { desc = "Split Window Below", remap = true }) map("n", "|", "v", { desc = "Split Window Right", remap = true }) map("n", "m", "NoNeckPain", { desc = "Toggle centered layout" }) -- Move to window using the hjkl keys map("n", "", "h", { desc = "Go to Left Window", remap = true }) map("n", "", "j", { desc = "Go to Lower Window", remap = true }) map("n", "", "k", { desc = "Go to Upper Window", remap = true }) map("n", "", "l", { desc = "Go to Right Window", remap = true }) map("n", "", "resize +2", { desc = "Increase Window Height" }) map("n", "", "resize -2", { desc = "Decrease Window Height" }) map("n", "", "vertical resize -2", { desc = "Decrease Window Width" }) map("n", "", "vertical resize +2", { desc = "Increase Window Width" }) -- Resize window using arrow keys map("n", "", "resize +2", { desc = "Increase Window Height" }) map("n", "", "resize -2", { desc = "Decrease Window Height" }) map("n", "", "vertical resize -2", { desc = "Decrease Window Width" }) map("n", "", "vertical resize +2", { desc = "Increase Window Width" }) -- quit map("n", "qq", "qa", { desc = "Quit All" }) --------------------------------------------------------------------------- -- LSP map("n", "gD", function() vim.lsp.buf.declaration() end, { desc = "LSP declaration" }) map("n", "gd", function() vim.lsp.buf.definition() end, { desc = "LSP definition" }) map("n", "gT", function() vim.lsp.buf.type_definition() end, { desc = "LSP type definition" }) map("n", "gr", function() vim.lsp.buf.references() end, { desc = "LSP references" }) map("n", "K", function() vim.lsp.buf.hover() end, { desc = "LSP hover" }) map("n", "gi", function() vim.lsp.buf.implementation() end, { desc = "LSP implementation" }) map("n", "ls", function() vim.lsp.buf.signature_help() end, { desc = "LSP signature help" }) map("n", "lf", function() vim.diagnostic.open_float({ border = "rounded" }) end, { desc = "Floating diagnostics" }) map("n", "ca", function() vim.lsp.buf.code_action() end, { desc = "LSP code actions" }) map("n", "[d", function() vim.diagnostic.goto_prev({ float = { border = "rounded" } }) end, { desc = "Goto prev diagnostic" }) map("n", "]d", function() vim.diagnostic.goto_next({ float = { border = "rounded" } }) end, { desc = "Goto next diagnostic" }) map("v", "ca", function() vim.lsp.buf.code_action() end, { desc = "LSP code action" }) map("n", "r", function() vim.lsp.buf.rename() end, { desc = "LSP rename" })