feat(nvim): remove a lot of keymaps i dont use

This commit is contained in:
Sergio Laín 2025-09-02 18:19:28 +02:00
parent f9b7b1533d
commit 7a0665fd03
No known key found for this signature in database
GPG key ID: 51BB28D8B42FB438

View file

@ -34,61 +34,13 @@ map("n", ">", ">>", { desc = "Indent" })
-- Save without formatting
map({ "n", "i" }, "<A-s>", "<cmd>noautocmd w<CR>", { desc = "Save Without Formatting" })
-- Cursor navigation on insert mode
map("i", "<M-h>", "<left>", { desc = "Move Cursor Left" })
map("i", "<M-l>", "<right>", { desc = "Move Cursor Left" })
map("i", "<M-j>", "<down>", { desc = "Move Cursor Left" })
map("i", "<M-k>", "<up>", { desc = "Move Cursor Left" })
-- End of the word backwards
map("n", "E", "ge")
-- Increment/decrement
map("n", "+", "<C-a>")
map("n", "-", "<C-x>")
-- Tabs
map("n", "]<tab>", "<cmd>tabnext<cr>", { desc = "Next Tab" })
map("n", "[<tab>", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })
map("n", "<tab>", "<cmd>tabnext<cr>", { desc = "Next Tab" })
map("n", "<s-tab>", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })
for i = 1, 9 do
map("n", "<leader><tab>" .. i, "<cmd>tabn " .. i .. "<cr>", { desc = "Tab " .. i })
end
map("n", "<leader>f<tab>", function()
vim.ui.select(vim.api.nvim_list_tabpages(), {
prompt = "Select Tab:",
format_item = function(tabid)
local wins = vim.api.nvim_tabpage_list_wins(tabid)
local not_floating_win = function(winid)
return vim.api.nvim_win_get_config(winid).relative == ""
end
wins = vim.tbl_filter(not_floating_win, wins)
local bufs = {}
for _, win in ipairs(wins) do
local buf = vim.api.nvim_win_get_buf(win)
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
if buftype ~= "nofile" then
local fname = vim.api.nvim_buf_get_name(buf)
table.insert(bufs, vim.fn.fnamemodify(fname, ":t"))
end
end
local tabnr = vim.api.nvim_tabpage_get_number(tabid)
local cwd = string.format(" %8s: ", vim.fn.fnamemodify(vim.fn.getcwd(-1, tabnr), ":t"))
local is_current = vim.api.nvim_tabpage_get_number(0) == tabnr and "" or " "
return tabnr .. is_current .. cwd .. table.concat(bufs, ", ")
end,
}, function(tabid)
if tabid ~= nil then
vim.cmd(tabid .. "tabnext")
end
end)
end, { desc = "Tabs" })
-- Buffers
map("n", "<leader>bf", "<cmd>bfirst<cr>", { desc = "First Buffer" })
map("n", "<leader>ba", "<cmd>blast<cr>", { desc = "Last Buffer" })
map("n", "<leader>b<tab>", "<cmd>tabnew %<cr>", { desc = "Current Buffer in New Tab" })
map("n", "<M-CR>", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
-- Toggle statusline
@ -100,10 +52,6 @@ map("n", "<leader>uS", function()
end
end, { desc = "Toggle Statusline" })
-- Comment box
map("n", "]/", "/\\S\\zs\\s*╭<CR>zt", { desc = "Next Block Comment" })
map("n", "[/", "?\\S\\zs\\s*╭<CR>zt", { desc = "Prev Block Comment" })
-- Plugin Info
map("n", "<leader>cif", "<cmd>LazyFormatInfo<cr>", { desc = "Formatting" })
map("n", "<leader>cic", "<cmd>ConformInfo<cr>", { desc = "Conform" })
@ -128,44 +76,16 @@ end
map("n", "<leader>ciL", linters, { desc = "Lint" })
map("n", "<leader>cir", "<cmd>LazyRoot<cr>", { desc = "Root" })
-- U for redo
map("n", "U", "<C-r>", { desc = "Redo" })
-- Copy whole text to clipboard
map("n", "<C-c>", ":%y+<CR>", { desc = "Copy Whole Text to Clipboard", silent = true })
-- Motion
map("c", "<C-a>", "<C-b>", { desc = "Start Of Line" })
map("i", "<C-a>", "<Home>", { desc = "Start Of Line" })
map("i", "<C-e>", "<End>", { desc = "End Of Line" })
-- Select all text
map("n", "<C-e>", "gg<S-V>G", { desc = "Select all Text", silent = true, noremap = true })
-- Paste options
map("i", "<C-v>", '<C-r>"', { desc = "Paste on Insert Mode" })
map("v", "p", '"_dP', { desc = "Paste Without Overwriting" })
-- Delete and change without yanking
map({ "n", "x" }, "<A-d>", '"_d', { desc = "Delete Without Yanking" })
map({ "n", "x" }, "<A-c>", '"_c', { desc = "Change Without Yanking" })
-- Deleting without yanking empty line
map("n", "dd", function()
local is_empty_line = vim.api.nvim_get_current_line():match("^%s*$")
if is_empty_line then
return '"_dd'
else
return "dd"
end
end, { noremap = true, expr = true, desc = "Don't Yank Empty Line to Clipboard" })
-- Search inside visually highlighted text
map("x", "g/", "<esc>/\\%V", { silent = false, desc = "Search Inside Visual Selection" })
-- Search visually selected text (slightly better than builtins in Neovim>=0.8)
map("x", "*", [[y/\V<C-R>=escape(@", '/\')<CR><CR>]], { desc = "Search Selected Text", silent = true })
map("x", "#", [[y?\V<C-R>=escape(@", '?\')<CR><CR>]], { desc = "Search Selected Text (Backwards)", silent = true })
-- Dashboard
map("n", "<leader>fd", function()
@ -215,13 +135,6 @@ map("n", "dm", function()
end
end, { noremap = true, desc = "Mark on Current Line" })
-- Empty Line
map("n", "gO", "<Cmd>call append(line('.') - 1, repeat([''], v:count1))<CR>", { desc = "Empty Line Above" })
map("n", "go", "<Cmd>call append(line('.'), repeat([''], v:count1))<CR>", { desc = "Empty Line Below" })
-- Insert Mode
map({ "c", "i", "t" }, "<M-BS>", "<C-w>", { desc = "Delete Word" })
-- Git
map("n", "<leader>ghb", Snacks.git.blame_line, { desc = "Blame Line" })