local map = vim.keymap.set -- generic -- prevents selected text we past over to be moved in a registry and override our paste map("x", "p", '"_dP') -- prevents the deleted text from going into the registry, use `d` for that map({ "n", "v", "x" }, "x", '"_d') map({ "n", "v", "x" }, "", '"_x') -- filthy casual save keybind map({ "n", "i" }, "", "w", { desc = "File Save" }) -- easy way to close the current buffer map("n", "", "bd!", { desc = "Close Buffer" }) -- moves the selection up or down using K and J (uppercase) map("v", "J", ":m '>+1gv=gv") map("v", "K", ":m '<-2gv=gv") -- terminal map("t", "", "") -- telescope map("n", "ff", "Telescope find_files", { desc = "[F]ind [F]iles" }) map("n", "fh", "Telescope help_tags", { desc = "[F]ind [H]elp" }) map("n", "fr", "Telescope oldfiles", { desc = "[F]ind [R]ecent" }) map( "n", "fsb", "Telescope current_buffer_fuzzy_find", { desc = "[F]ind [S]tring in current [B]uffer" } ) map("n", "fsg", "Telescope live_grep", { desc = "[F]ind [S]tring [G]lobal" }) map("n", "fgg", "Telescope git_files", { desc = "[F]ind [G]it" }) map("n", "fgs", "Telescope git_status", { desc = "[F]ind [G]it [S]tatus" }) map("n", "fgc", "Telescope git_commits", { desc = "[F]ind [G]it [C]ommits" }) map( "n", "", "Telescope buffers sort_mru=true sort_lastused=true ignore_current_buffer=true", { desc = "[ ] Find Buffers" } ) -- lsp map("n", "gd", "Telescope lsp_definitions", { desc = "[G]oto [D]efinition" }) map("n", "gr", "Telescope lsp_references", { desc = "[G]oto [R]eferences" }) map("n", "gI", "Telescope lsp_implementations", { desc = "[G]oto [I]mplementations" }) map("n", "gD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" }) map("n", "", function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = 0 })) end, { desc = "Toggle Inlay Hint" }) map("n", "ca", vim.lsp.buf.code_action, { desc = "[C]ode [A]ction" }) map("n", "cf", vim.lsp.buf.format, { desc = "[C]ode [F]ormat" }) map("n", "ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, { desc = "[W]orkspace [S]ymbols" }) map("n", "ds", require("telescope.builtin").lsp_document_symbols, { desc = "[D]ocument [S]ymbols" }) map("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" }) -- neo-tree map("n", "n", "Neotree toggle", { desc = "Toggle Filetree Window" }) map("n", "e", "Neotree focus", { desc = "Focus Filetree Window" }) -- minimap map("n", "m", MiniMap.toggle, { desc = "Toggle Minimap" }) -- comment -- _ represents the / key here local comment_api = require("Comment.api") map({ "n", "i" }, "", function() comment_api.toggle.linewise.current() end, { desc = "Toggle Comment" }) map("x", "", function() local esc = vim.api.nvim_replace_termcodes("", true, false, true) vim.api.nvim_feedkeys(esc, "nx", false) comment_api.toggle.linewise(vim.fn.visualmode()) end, { desc = "Toggle Comment" }) -- trouble map("n", "td", "Trouble diagnostics toggle", { desc = "[T]rouble [D]iagnostics" }) map( "n", "te", "Trouble diagnostics toggle filter.severity=vim.diagnostic.severity.ERROR", { desc = "[T]rouble [E]rrors" } ) map("n", "tt", "Trouble todo toggle", { desc = "[T]rouble [T]odo" }) -- whichkey map("n", "wK", "WhichKey", { desc = "Whichkey show all keymaps" })