1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
local map = vim.keymap.set
map("v", "<leader>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", "<leader>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", "<leader>bd", ":bd!<CR>", { desc = "Deletes the current buffer" })
map("n", "<leader>fz", function()
vim.cmd [[normal zfaf]]
end, { desc = "Fold the function" })
-- lists navigation
map("n", "<C-j>", ":cnext<CR>zz", { desc = "Goes to the next item in the quickfixlist and center to the screen" })
map("n", "<C-k>", ":cprev<CR>zz", { desc = "Goes to the previous item in the quickfixlist and center to the screen" })
-- map("n", "<leader>i", ":lnext<CR>zz")
-- map("n", "<leader>o", ":lprev<CR>zz")
map("n", "<leader>cc", ":cclose<CR>", { desc = "Close the quick fix list" })
map("n", "<leader><leader><leader>tc", ":TSContextToggle<CR>", { desc = "Toggle treesitter context" })
-- tabulation
map("v", "<", "<gv", { desc = "Indent out and keeps the selection" })
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 .. "<c-g>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", "<Esc><Esc>", "<C-\\><C-n>")
map("t", "<C-w>h", "<C-\\><C-n><C-w>h")
map("t", "<C-w>j", "<C-\\><C-n><C-w>j")
map("t", "<C-w>k", "<C-\\><C-n><C-w>k")
map("t", "<C-w>l", "<C-\\><C-n><C-w>l")
-- quick env file edit
map("n", "<leader>ee", ":vsp .env<CR>", { desc = "Open .env file in a vertical split" })
-- quick save and exec
map(
"n",
"<leader><leader>x",
require("pi.utils").save_and_exec,
{ desc = "Save the current file and source it for .vim and .lua files" }
)
map("n", "<leader>vn", function()
vim.diagnostic.jump { count = 1, float = true }
end, { desc = "Goes to next diagnostic error" })
map("n", "<leader>vp", function()
vim.diagnostic.jump { count = -1, float = true }
end, { desc = "Goes to prev diagnostic error" })
map("v", "<leader>q", require("pi.select_to_quickfix").handle)
map("n", "99", ":set invspell<CR>", { noremap = true })
-- map("n", "<leader>ss", function() require('nvim-python-repl').send_statement_definition() end, { desc = "Send semantic unit to REPL"})
vim.api.nvim_set_keymap(
"n",
"<C-Enter>",
[[<Esc>:lua require('nvim-python-repl').send_statement_definition()<CR>j]],
{ noremap = true, silent = true }
)
vim.api.nvim_set_keymap(
"i",
"<C-Enter>",
[[<Esc>:lua require('nvim-python-repl').send_statement_definition()<CR>i]],
{ noremap = true, silent = true }
)
map("n", "<leader>sl", function()
require("nvim-python-repl").send_visual_to_repl()
end, { desc = "Send visual selection to REPL" })
map("v", "<leader>sl", function()
require("nvim-python-repl").send_visual_to_repl()
end, { desc = "Send visual selection to REPL" })
map("n", "<leader>MReturn", function()
require("nvim-python-repl").send_buffer_to_repl()
end, { desc = "Send entire buffer to REPL" })
map("n", "<leader>e", function()
require("nvim-python-repl").toggle_execute()
end, { desc = "Automatically execute command in REPL after sent" })
map("n", "<leader>vi", function()
require("nvim-python-repl").toggle_vertical()
end, { desc = "Create REPL in vertical or horizontal split" })
map("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
map("n", "<leader>fg", function()
require("telescope").extensions.live_grep_args.live_grep_args()
end, { desc = "run grep" })
-- Asignar la función a una tecla específica
vim.api.nvim_set_keymap("n", "<leader>w", ":lua ToggleWrap()<CR>", { noremap = true, silent = true })
map("n", "<leader>rrn", ":RustLsp runnables<CR>", { desc = "run rust" })
vim.keymap.set("n", "<leader>pdm", function()
require("dap-python").test_method()
end)
vim.keymap.set("n", "<leader>pdc", function()
require("dap-python").test_class()
end)
vim.keymap.set("n", "<leader>pdf", function()
require("dap-python").test_file()
end)
map("n", "<leader>ft", "<CMD>FloatermToggle<CR>", { desc = "run terminal" })
|