feat(gitsigns): reworked as suggested in PR comments

This commit is contained in:
Oleg Kostyuk 2026-04-17 00:03:55 +02:00
parent 397e1c3a2b
commit b3ac8a8aec
3 changed files with 42 additions and 9 deletions

10
NEWS.md
View file

@ -20,10 +20,12 @@ Going forward, **LazyVim** requires **Neovim** `>= 0.11.2`, and drops support fo
### Keymaps ### Keymaps
- `<leader>hq` to show hunks as Quickfix [gitsigns](https://github.com/lewis6991/gitsigns.nvim) - `<leader>uH` to toggle LSP Codelens [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
- `<leader>hQ` to show hunks as Quickfix (all files) [gitsigns](https://github.com/lewis6991/gitsigns.nvim) - `<leader>sp` to pick a picker [fzf-lua](https://github.com/ibhagwan/fzf-lua)
- `<leader>tb` to toggle current line blame [gitsigns](https://github.com/lewis6991/gitsigns.nvim) - `<leader>xh` to show file hunks as Quickfix [gitsigns](https://github.com/lewis6991/gitsigns.nvim)
- `<leader>tw` to toggle word diff [gitsigns](https://github.com/lewis6991/gitsigns.nvim) - `<leader>xH` to show project hunks as Quickfix [gitsigns](https://github.com/lewis6991/gitsigns.nvim)
- `<leader>uB` to toggle current line blame [gitsigns](https://github.com/lewis6991/gitsigns.nvim)
- `<leader>uW` to toggle word diff [gitsigns](https://github.com/lewis6991/gitsigns.nvim)
- `<leader>rI` to inline function [refactoring](https://github.com/ThePrimeagen/refactoring.nvim) - `<leader>rI` to inline function [refactoring](https://github.com/ThePrimeagen/refactoring.nvim)
## 14.x ## 14.x

View file

@ -72,7 +72,6 @@ return {
{ "<leader>f", group = "file/find" }, { "<leader>f", group = "file/find" },
{ "<leader>g", group = "git" }, { "<leader>g", group = "git" },
{ "<leader>gh", group = "hunks" }, { "<leader>gh", group = "hunks" },
{ "<leader>gt", group = "toggle" },
{ "<leader>q", group = "quit/session" }, { "<leader>q", group = "quit/session" },
{ "<leader>s", group = "search" }, { "<leader>s", group = "search" },
{ "<leader>u", group = "ui" }, { "<leader>u", group = "ui" },
@ -184,11 +183,10 @@ return {
map("n", "<leader>ghB", function() gs.blame() end, "Blame Buffer") map("n", "<leader>ghB", function() gs.blame() end, "Blame Buffer")
map("n", "<leader>ghd", gs.diffthis, "Diff This") map("n", "<leader>ghd", gs.diffthis, "Diff This")
map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~") map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
map("n", "<leader>ghq", gs.setqflist, "Show hunks as Quickfix")
map("n", "<leader>ghQ", function() gs.setqflist("all") end, "Show hunks as Quickfix (all)")
map("n", "<leader>gtb", gs.toggle_current_line_blame, "Toggle current line blame")
map("n", "<leader>gtw", gs.toggle_word_diff, "Toggle word diff")
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk") map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk")
map("n", "<leader>xh", gs.setqflist, "Git hunks (file)")
map("n", "<leader>xH", function() gs.setqflist("all") end, "Git hunks (all)")
end, end,
}, },
}, },
@ -204,6 +202,38 @@ return {
require("gitsigns").toggle_signs(state) require("gitsigns").toggle_signs(state)
end, end,
}):map("<leader>uG") }):map("<leader>uG")
Snacks.toggle({
name = "Git Line Blame",
get = function()
return require("gitsigns.config").config.current_line_blame
end,
set = function(state)
require("gitsigns").toggle_current_line_blame(state)
end,
}):map("<leader>uB")
Snacks.toggle({
name = "Git Word Diff",
get = function()
return require("gitsigns.config").config.word_diff
end,
set = function(state)
require("gitsigns").toggle_word_diff(state)
end,
}):map("<leader>uW")
end,
},
{
"neovim/nvim-lspconfig",
opts = function()
Snacks.toggle({
name = "LSP Codelens",
get = function()
return vim.lsp.codelens.is_enabled()
end,
set = function(state)
vim.lsp.codelens.enable(state)
end,
}):map("<leader>uH")
end, end,
}, },

View file

@ -249,6 +249,7 @@ return {
{ "<leader>sl", "<cmd>FzfLua loclist<cr>", desc = "Location List" }, { "<leader>sl", "<cmd>FzfLua loclist<cr>", desc = "Location List" },
{ "<leader>sM", "<cmd>FzfLua man_pages<cr>", desc = "Man Pages" }, { "<leader>sM", "<cmd>FzfLua man_pages<cr>", desc = "Man Pages" },
{ "<leader>sm", "<cmd>FzfLua marks<cr>", desc = "Jump to Mark" }, { "<leader>sm", "<cmd>FzfLua marks<cr>", desc = "Jump to Mark" },
{ "<leader>sp", "<cmd>FzfLua builtin fuzzy=true<cr>", desc = "FZF pickers" },
{ "<leader>sR", "<cmd>FzfLua resume<cr>", desc = "Resume" }, { "<leader>sR", "<cmd>FzfLua resume<cr>", desc = "Resume" },
{ "<leader>sq", "<cmd>FzfLua quickfix<cr>", desc = "Quickfix List" }, { "<leader>sq", "<cmd>FzfLua quickfix<cr>", desc = "Quickfix List" },
{ "<leader>sw", LazyVim.pick("grep_cword"), desc = "Word (Root Dir)" }, { "<leader>sw", LazyVim.pick("grep_cword"), desc = "Word (Root Dir)" },