local map = vim.keymap.set map("v", "p", function() local val = vim.fn.getreg "+" vim.api.nvim_command [[normal! p]] vim.fn.setreg("+", val) end, { desc = "Special paste, paste without replacing copy register content" }) map("n", "mm", function() local items = vim.fn.systemlist "make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\/\t=]*:([^=]|$)/ {split($1,A,/ /);print A[1]}'" vim.ui.select(items, { promt = "Make command" }, function(choice) if not choice then return end require("harpoon.term").sendCommand(1, "make " .. choice) end) end) map("n", "bd", ":bd!", { desc = "Deletes the current buffer" }) map("n", "fz", function() vim.cmd [[normal zfaf]] end, { desc = "Fold the function" }) -- lists navigation map("n", "", ":cnextzz", { desc = "Goes to the next item in the quickfixlist and center to the screen" }) map("n", "", ":cprevzz", { desc = "Goes to the previous item in the quickfixlist and center to the screen" }) -- map("n", "i", ":lnextzz") -- map("n", "o", ":lprevzz") map("n", "cc", ":cclose", { desc = "Close the quick fix list" }) -- Toggle de diagnósticos en quickfix (reemplaza trouble.nvim) map("n", "t", function() local qf_open = false for _, win in ipairs(vim.fn.getwininfo()) do if win.quickfix == 1 then qf_open = true end end if qf_open then vim.cmd "cclose" else vim.diagnostic.setqflist() end end, { desc = "Toggle diagnostics quickfix list" }) -- Navegación entre referencias del símbolo bajo el cursor (snacks.words; reemplaza vim-illuminate) map("n", "]r", function() Snacks.words.jump(1, true) end, { desc = "Next Reference" }) map("n", "[r", function() Snacks.words.jump(-1, true) end, { desc = "Previous Reference" }) -- Modo sin distracciones (reemplaza zen-mode.nvim) map("n", "cz", function() Snacks.zen() end, { desc = "Distraction Free Mode" }) -- Git worktrees (reemplaza git-worktree.nvim) map("n", "gt", function() require("config.worktree").switch() end, { desc = "Git Worktree switch" }) map("n", "gn", function() require("config.worktree").create() end, { desc = "Git Worktree new branch" }) -- Redimensionar ventanas (reemplaza smart-splits.nvim) map("n", "", "vertical resize -3", { desc = "Resize window: narrower" }) map("n", "", "vertical resize +3", { desc = "Resize window: wider" }) map("n", "", "resize +3", { desc = "Resize window: taller" }) map("n", "", "resize -3", { desc = "Resize window: shorter" }) map("n", "tc", ":TSContextToggle", { desc = "Toggle treesitter context" }) -- tabulation map("v", "<", "", ">gv", { desc = "Indent in and keeps the selection" }) -- symbols to add undo points local symbols = { ",", ".", "!", "?", "$", ">", "<" } for _, symbol in pairs(symbols) do map("i", symbol, symbol .. "u", { desc = string.format("Add symbol %s to the undo list and writes it", symbol) }) end -- search result focus map("n", "n", "nzzzv", { desc = "Goes to next result on the search and put the cursor in the middle of the screen" }) map("n", "N", "Nzzzv", { desc = "Goes to prev result on the search and put the cursor in the middle of the screen" }) -- join lines focus map("n", "J", "mzJ`z", { desc = "Join lines and keep in the same place the cursor" }) -- Terminal map("t", "", "") map("t", "h", "h") map("t", "j", "j") map("t", "k", "k") map("t", "l", "l") -- quick env file edit map("n", "ee", ":vsp .env", { desc = "Open .env file in a vertical split" }) -- quick save and exec map( "n", "x", require("pi.utils").save_and_exec, { desc = "Save the current file and source it for .vim and .lua files" } ) map("n", "vn", function() vim.diagnostic.jump { count = 1, float = true } end, { desc = "Goes to next diagnostic error" }) map("n", "vp", function() vim.diagnostic.jump { count = -1, float = true } end, { desc = "Goes to prev diagnostic error" }) map("v", "q", require("pi.select_to_quickfix").handle) map("n", "99", ":set invspell", { noremap = true }) -- map("n", "ss", function() require('nvim-python-repl').send_statement_definition() end, { desc = "Send semantic unit to REPL"}) vim.api.nvim_set_keymap( "n", "", [[:lua require('nvim-python-repl').send_statement_definition()j]], { noremap = true, silent = true } ) vim.api.nvim_set_keymap( "i", "", [[:lua require('nvim-python-repl').send_statement_definition()i]], { noremap = true, silent = true } ) map("n", "sl", function() require("nvim-python-repl").send_visual_to_repl() end, { desc = "Send visual selection to REPL" }) map("v", "sl", function() require("nvim-python-repl").send_visual_to_repl() end, { desc = "Send visual selection to REPL" }) map("n", "MReturn", function() require("nvim-python-repl").send_buffer_to_repl() end, { desc = "Send entire buffer to REPL" }) map("n", "e", function() require("nvim-python-repl").toggle_execute() end, { desc = "Automatically execute command in REPL after sent" }) map("n", "vi", function() require("nvim-python-repl").toggle_vertical() end, { desc = "Create REPL in vertical or horizontal split" }) map("n", "-", "Oil", { desc = "Open parent directory" }) map("n", "fg", function() Snacks.picker.grep() end, { desc = "run grep" }) -- Asignar la función a una tecla específica vim.api.nvim_set_keymap("n", "w", ":lua ToggleWrap()", { noremap = true, silent = true }) map("n", "rrn", ":RustLsp runnables", { desc = "run rust" }) vim.keymap.set("n", "pdm", function() require("dap-python").test_method() end) vim.keymap.set("n", "pdc", function() require("dap-python").test_class() end) vim.keymap.set("n", "pdf", function() require("dap-python").test_file() end) map("n", "ft", "FloatermToggle", { desc = "run terminal" }) -- CodeCompanion map({ "n", "v" }, "", "CodeCompanionActions", { noremap = true, silent = true }) map({ "n", "v" }, "a", "CodeCompanionChat Toggle", { noremap = true, silent = true }) map("v", "ga", "CodeCompanionChat Add", { noremap = true, silent = true }) -- Historial de notificaciones (reemplaza :Noice history) map("n", "nh", function() Snacks.notifier.show_history() end, { desc = "Historial de notificaciones" }) -- Abrir archivo/selección en el navegador (reemplaza vim-rhubarb :GBrowse) map({ "n", "v" }, "go", function() Snacks.gitbrowse() end, { desc = "Git browse en el navegador" }) -- Picker de iconos/emoji (reemplaza icon-picker.nvim) map("n", "i", function() Snacks.picker.icons() end, { desc = "Insertar icono/emoji" }) map("n", "y", function() Snacks.picker.icons { confirm = "yank" } end, { desc = "Copiar icono/emoji" }) map("i", "", function() Snacks.picker.icons() end, { desc = "Insertar icono/emoji" }) -- Menú de acciones de Oil vía vim.ui.select (reemplaza menu.nvim) map("n", "um", function() local items = vim.tbl_filter(function(item) return item.cmd ~= nil end, require "menus.oil") vim.ui.select(items, { prompt = "Oil", format_item = function(item) return item.name .. (item.rtxt and " (" .. item.rtxt .. ")" or "") end, }, function(choice) if choice then choice.cmd() end end) end, { desc = "Abrir menú de Oil" }) -- Animación de retipeo del buffer (antes plugin animation.nvim) map("n", "AA", function() require("pi.animations").redraw_buffer() end, { desc = "Retype buffer animation" }) -- Buffers abiertos y navegación entre ellos (reemplaza buffer_manager.nvim, -- roto en Neovim: usa el autocmd BufModifiedSet, que Vim soporta pero Neovim no implementa) map("n", "o", function() Snacks.picker.buffers() end, { desc = "Buffers abiertos" }) map("n", "]b", ":bnext", { desc = "Buffer siguiente" }) map("n", "[b", ":bprevious", { desc = "Buffer anterior" })