2022-10-01 11:46:18 +00:00
|
|
|
-- Shorten function name
|
|
|
|
local keymap = vim.keymap.set
|
|
|
|
-- Silent keymap option
|
2023-11-05 18:31:25 +00:00
|
|
|
local opts = { noremap = true, silent = true }
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
--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",
|
|
|
|
|
2023-04-05 19:25:04 +00:00
|
|
|
-- Kitty navigation
|
|
|
|
vim.g.kitty_navigator_no_mappings = 1
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap("n", "<A-Left>", ":KittyNavigateLeft<cr>", vim.tbl_extend("force", opts, { desc = "Navigate left" }))
|
|
|
|
keymap("n", "<A-Down>", ":KittyNavigateDown<cr>", vim.tbl_extend("force", opts, { desc = "Navigate down" }))
|
|
|
|
keymap("n", "<A-Up>", ":KittyNavigateUp<cr>", vim.tbl_extend("force", opts, { desc = "Navigate up" }))
|
|
|
|
keymap("n", "<A-Right>", ":KittyNavigateRight<cr>", vim.tbl_extend("force", opts, { desc = "Navigate right" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Resize with arrows
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap("n", "<C-Up>", ":resize -2<cr>", vim.tbl_extend("force", opts, { desc = "Window horizontal resize -2" }))
|
|
|
|
keymap("n", "<C-Down>", ":resize +2<cr>", vim.tbl_extend("force", opts, { desc = "Window horizontal resize +2" }))
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<C-Left>",
|
|
|
|
":vertical resize -2<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Window vertical resize -2" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<C-Right>",
|
|
|
|
":vertical resize +2<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Window vertical resize +2" })
|
|
|
|
)
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Navigate buffers
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<C-PageDown>",
|
|
|
|
":bnext<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the next buffer on the right" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<C-PageUp>",
|
|
|
|
":bprevious<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the previous buffer on the left" })
|
|
|
|
)
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Clear highlights
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap("n", "<leader>h", "<cmd>nohlsearch<cr>", vim.tbl_extend("force", opts, { desc = "Clear search highlights" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Close buffers
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap("n", "<S-q>", "<cmd>Bdelete!<cr>", vim.tbl_extend("force", opts, { desc = "Close buffer" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
2022-11-12 17:39:10 +00:00
|
|
|
-- LSP / Diagnostics
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>xx",
|
2024-04-13 17:03:34 +00:00
|
|
|
"<cmd>Trouble diagnostics toggle<cr>",
|
2023-11-05 18:31:25 +00:00
|
|
|
vim.tbl_extend("force", opts, { desc = "Toggle trouble diganostics" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>xd",
|
2024-04-13 17:03:34 +00:00
|
|
|
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Toggle trouble buffer diganostics" })
|
2023-11-05 18:31:25 +00:00
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"K",
|
|
|
|
"<cmd>Lspsaga hover_doc<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Show a hover window with the documentation" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"E",
|
|
|
|
"<cmd>Lspsaga show_line_diagnostics<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Show a hover window with the diagnostics of the error" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"gd",
|
|
|
|
"<cmd>Lspsaga finder<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Show a hover window with the usage of the directive under the cursor" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>ld",
|
|
|
|
"<cmd>Lspsaga goto_definition<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the definition of the directive under the cursor" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>la",
|
|
|
|
"<cmd>Lspsaga code_action<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Show available code actions for the line under the cursor" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>lj",
|
|
|
|
"<cmd>Lspsaga diagnostic_jump_next<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the next diagnostic in the buffer" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>lk",
|
|
|
|
"<cmd>Lspsaga diagnostic_jump_prev<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the previous diagnostic in the buffer" })
|
|
|
|
)
|
2023-11-19 15:04:40 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>lr",
|
2024-02-12 19:46:40 +00:00
|
|
|
"<cmd>Lspsaga rename mode=n<cr>",
|
2023-11-19 15:04:40 +00:00
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a dialog to rename a code element" })
|
|
|
|
)
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>lp",
|
|
|
|
"<cmd>Lspsaga peek_definition<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Peek the definition of the directive under the cursor" })
|
|
|
|
)
|
2024-06-08 13:09:31 +00:00
|
|
|
keymap({ "n", "v" }, "<leader>lf", function()
|
|
|
|
require("conform").format({ async = true, lsp_fallback = true })
|
|
|
|
end, vim.tbl_extend("force", opts, { desc = "Format the current buffer or selection" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
2024-02-04 16:55:49 +00:00
|
|
|
-- Neotest
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>tr",
|
|
|
|
"<cmd>RunTest<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Run test on the current function" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>tf",
|
|
|
|
"<cmd>RunTestFile<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Run tests on the current file" })
|
|
|
|
)
|
|
|
|
|
2024-02-12 19:46:40 +00:00
|
|
|
-- Copilot
|
2024-05-01 11:05:42 +00:00
|
|
|
keymap({ "n", "v" }, "<leader>coh", function()
|
2024-03-17 17:25:34 +00:00
|
|
|
local actions = require("CopilotChat.actions")
|
|
|
|
require("CopilotChat.integrations.telescope").pick(actions.help_actions())
|
2024-02-16 15:37:22 +00:00
|
|
|
end, vim.tbl_extend("force", opts, { desc = "CopilotChat - Help actions" }))
|
2024-05-01 11:05:42 +00:00
|
|
|
keymap({ "n", "v" }, "<leader>cop", function()
|
2024-03-17 17:25:34 +00:00
|
|
|
local actions = require("CopilotChat.actions")
|
|
|
|
require("CopilotChat.integrations.telescope").pick(actions.prompt_actions())
|
2024-02-16 15:37:22 +00:00
|
|
|
end, vim.tbl_extend("force", opts, { desc = "CopilotChat - Prompt actions" }))
|
2024-05-01 11:05:42 +00:00
|
|
|
keymap("n", "<leader>coq", function()
|
|
|
|
local input = vim.fn.input("Quick Chat: ")
|
|
|
|
if input ~= "" then
|
|
|
|
require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer })
|
|
|
|
end
|
|
|
|
end, vim.tbl_extend("force", opts, { desc = "CopilotChat - Quick chat" }))
|
2024-02-12 19:46:40 +00:00
|
|
|
|
2022-10-01 11:46:18 +00:00
|
|
|
-- Better paste
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap("v", "p", "P", vim.tbl_extend("force", opts, { desc = "Paste" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
2024-02-04 16:55:49 +00:00
|
|
|
-- Press jk fast to exit insert mode
|
|
|
|
keymap("i", "jk", "<ESC>", vim.tbl_extend("force", opts, { desc = "Exit insert mode" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Stay in indent mode
|
|
|
|
keymap("v", "<", "<gv", opts)
|
|
|
|
keymap("v", ">", ">gv", opts)
|
|
|
|
|
|
|
|
-- NeoTree
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap("n", "<leader>e", ":Neotree toggle<cr>", vim.tbl_extend("force", opts, { desc = "Toggle Neotree" }))
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>gg",
|
|
|
|
":Neotree float git_status<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a float window with the git status" })
|
|
|
|
)
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Telescope
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>ff",
|
|
|
|
":Telescope find_files<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to search for files" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<C-p>",
|
|
|
|
":Telescope find_files<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to search for files" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>fg",
|
|
|
|
":Telescope live_grep<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to search for text in all files" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>fk",
|
|
|
|
":Telescope keymaps<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to show all keymaps" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>fc",
|
|
|
|
":Telescope commands<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to show all commands" })
|
|
|
|
)
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
-- Comment
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>/",
|
|
|
|
"<cmd>lua require'Comment.api'.toggle.linewise.current()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Comment/Uncomment code lines" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"x",
|
|
|
|
"<leader>/",
|
|
|
|
"<esc><cmd>lua require'Comment.api'.toggle.linewise(vim.fn.visualmode())<cr>",
|
2023-11-19 15:04:40 +00:00
|
|
|
vim.tbl_extend("force", opts, { desc = "Comment/Uncomment code lines on visual block mode" })
|
2023-11-05 18:31:25 +00:00
|
|
|
)
|
2023-03-26 10:43:25 +00:00
|
|
|
|
|
|
|
-- Gitdiff
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>df",
|
|
|
|
":DiffviewFileHistory %<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open diff view file history for the current buffer" })
|
|
|
|
)
|
|
|
|
keymap("n", "<leader>dc", ":DiffviewClose<cr>", vim.tbl_extend("force", opts, { desc = "Close diff view" }))
|
2022-10-01 11:46:18 +00:00
|
|
|
|
2023-09-28 16:17:05 +00:00
|
|
|
-- Projects
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<leader>fp",
|
|
|
|
":Telescope neovim-project discover<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open a Telescope prompt to search for projects" })
|
|
|
|
)
|
2022-11-09 18:22:40 +00:00
|
|
|
|
|
|
|
-- Base64
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"v",
|
|
|
|
"<leader>64e",
|
|
|
|
":<c-u>lua require'b64'.encode()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Encode the visual selected text to base64" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"v",
|
|
|
|
"<leader>64d",
|
|
|
|
":<c-u>lua require'b64'.decode()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Decode the visual selected text from base64" })
|
|
|
|
)
|
2022-11-12 17:39:10 +00:00
|
|
|
|
|
|
|
-- Illuminate
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<A-n>",
|
|
|
|
"<cmd>lua require'illuminate'.next_reference{wrap=true}<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the next selected text by illuminate" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"<A-p>",
|
|
|
|
"<cmd>lua require'illuminate'.next_reference{reverse=true,wrap=true}<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Navigate to the previous selected text by illuminate" })
|
|
|
|
)
|
2023-10-14 12:17:52 +00:00
|
|
|
|
|
|
|
-- Folding
|
2023-11-05 18:31:25 +00:00
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"zR",
|
|
|
|
"<cmd>lua require'ufo'.openAllFolds()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Open all folds" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"zM",
|
|
|
|
"<cmd>lua require'ufo'.closeAllFolds()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Close all folds" })
|
|
|
|
)
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"zr",
|
|
|
|
"<cmd>lua require'ufo'.openFoldsExceptKinds()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Fold less" })
|
|
|
|
)
|
|
|
|
keymap("n", "zm", "<cmd>lua require'ufo'.closeFoldsWith()<cr>", vim.tbl_extend("force", opts, { desc = "Fold more" }))
|
|
|
|
keymap(
|
|
|
|
"n",
|
|
|
|
"zp",
|
|
|
|
"<cmd>lua require'ufo'.peekFoldedLinesUnderCursor()<cr>",
|
|
|
|
vim.tbl_extend("force", opts, { desc = "Peek fold" })
|
|
|
|
)
|