refactor(nvim): Keymap updates for git, symbol search & save/quit

- Treesitter: `]a` -> next arg, `[a` -> previous arg, `]T` -> next test
- git: Revert Previous & next hunks to `]g` & `[g`
- git: Remove `<space>gK` for hover blame-line: use `<space>gL` instead
- save: Save all files with `<C-s>`,
- exit: Quit without saving with `<C-q>`: won't exit with unsaved files:
  sometime you don't want to save files
- Search symbols with `<space>s` & `<space>S` instead of `<space>cs` &
  `<space>cS`
This commit is contained in:
Pratik Tripathy
2025-11-22 23:49:12 +05:30
parent e68d0b3529
commit 8c6278d7b6
5 changed files with 14 additions and 13 deletions

View File

@@ -34,8 +34,8 @@ vim.keymap.set("i", ";", ";<C-g>u", { desc = "Auto add undo breakpoints on ';'"
vim.keymap.set("i", "\r", "\r<C-g>u", { desc = "Auto add undo breakpoints on new lines" }) vim.keymap.set("i", "\r", "\r<C-g>u", { desc = "Auto add undo breakpoints on new lines" })
-- Save file -- Save file
vim.keymap.set({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" }) vim.keymap.set({ "i", "x", "n", "s" }, "<C-s>", "<cmd>wa<cr><esc>", { desc = "Save all files" })
vim.keymap.set({ "i", "x", "n", "s" }, "<C-q>", "<cmd>wqa<cr><esc>", { desc = "Save all files and Quit Neovim" }) vim.keymap.set({ "i", "x", "n", "s" }, "<C-q>", "<cmd>q<cr><esc>", { desc = "Quit Neovim without saving" })
-- Close Current Buffer -- Close Current Buffer
vim.keymap.set({ "n", "v" }, "<leader>bx", function() vim.keymap.set({ "n", "v" }, "<leader>bx", function()

View File

@@ -74,8 +74,8 @@ vim.api.nvim_create_autocmd("LspAttach", {
-- Telescope -- Telescope
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
map("<leader>cs", require("telescope.builtin").lsp_document_symbols, "Search Document Symbols") map("<leader>s", require("telescope.builtin").lsp_document_symbols, "Search Document Symbols")
map("<leader>cS", require("telescope.builtin").lsp_workspace_symbols, "Search Workspace Symbols") map("<leader>S", require("telescope.builtin").lsp_workspace_symbols, "Search Workspace Symbols")
map("<leader>ct", require("telescope.builtin").lsp_type_definitions, "Goto Type Definition") map("<leader>ct", require("telescope.builtin").lsp_type_definitions, "Goto Type Definition")
Snacks.toggle({ Snacks.toggle({

View File

@@ -269,10 +269,13 @@ return {
move = { move = {
-- Jump to next and previous text objects -- Jump to next and previous text objects
-- ]a -> next argument
-- ]T -> next test
enable = true, enable = true,
goto_next_start = { goto_next_start = {
["]f"] = { query = "@function.outer", desc = "Goto next inner function start" }, ["]f"] = { query = "@function.outer", desc = "Goto next inner function start" },
["]o"] = { query = "@loop.*", desc = "Goto next loop start" }, ["]o"] = { query = "@loop.*", desc = "Goto next loop start" },
["]a"] = { query = "@parameter.inner", desc = "Goto next parameter" },
}, },
goto_next_end = { goto_next_end = {
["]F"] = { query = "@function.outer", desc = "Goto next outer function end" }, ["]F"] = { query = "@function.outer", desc = "Goto next outer function end" },
@@ -282,6 +285,7 @@ return {
goto_previous_start = { goto_previous_start = {
["[f"] = { query = "@function.outer", desc = "Goto goto previous inner function start" }, ["[f"] = { query = "@function.outer", desc = "Goto goto previous inner function start" },
["[o"] = { query = "@loop.*", desc = "Goto previous loop start" }, ["[o"] = { query = "@loop.*", desc = "Goto previous loop start" },
["[a"] = { query = "@parameter.inner", desc = "Goto previous parameter" },
}, },
goto_previous_end = { goto_previous_end = {
["[F"] = { query = "@function.outer", desc = "Goto goto previous outer function start" }, ["[F"] = { query = "@function.outer", desc = "Goto goto previous outer function start" },

View File

@@ -53,11 +53,11 @@ return {
-- Text object -- Text object
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", { desc = "Git: Visual select hunk" }) map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", { desc = "Git: Visual select hunk" })
map({ "n", "v" }, "]h", function() map({ "n", "v" }, "]g", function()
gs.next_hunk() gs.next_hunk()
end, { desc = "Next Git hunk" }) end, { desc = "Next Git hunk" })
map({ "n", "v" }, "[h", function() map({ "n", "v" }, "[g", function()
gs.prev_hunk() gs.prev_hunk()
end, { desc = "Previous Git hunk" }) end, { desc = "Previous Git hunk" })
@@ -73,10 +73,6 @@ return {
map("n", "<leader>gp", gs.preview_hunk, { desc = "Git: Preview hunk" }) map("n", "<leader>gp", gs.preview_hunk, { desc = "Git: Preview hunk" })
map("n", "<leader>gs", gs.stage_hunk, { desc = "Git: Toggle Stage-Hunk" }) map("n", "<leader>gs", gs.stage_hunk, { desc = "Git: Toggle Stage-Hunk" })
map("n", "<leader>gK", function()
gs.blame_line({ full = true })
end, { desc = "Git: Hover blame-line" })
map("n", "<leader>gB", gs.toggle_current_line_blame, { desc = "Git: Toggle virtual blame-line" }) map("n", "<leader>gB", gs.toggle_current_line_blame, { desc = "Git: Toggle virtual blame-line" })
end, end,
}, },

View File

@@ -90,9 +90,10 @@ nnoremap <expr> N 'nN'[v:searchforward]
xnoremap <expr> N 'nN'[v:searchforward] xnoremap <expr> N 'nN'[v:searchforward]
onoremap <expr> N 'nN'[v:searchforward] onoremap <expr> N 'nN'[v:searchforward]
" <ctrl-q> to save everything and quit Neovim " <ctrl-q> Quit Vim (without saving)
nnoremap <C-q> :wqa<CR> " <ctrl-s> Save all buffers
vnoremap <C-q> :wqa<CR> nnoremap <C-q> :q<CR>
vnoremap <C-q> :q<CR>
nnoremap <C-s> :wa<CR> nnoremap <C-s> :wa<CR>
vnoremap <C-s> :wa<CR> vnoremap <C-s> :wa<CR>