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