feat(nvim): add visual git stage bind

This commit is contained in:
matt1432 2023-10-30 20:24:47 -04:00
parent 0a0b493de1
commit fbe8d06de1
2 changed files with 16 additions and 1 deletions

View file

@ -161,7 +161,7 @@ in {
{ {
plugin = gitsigns-nvim; plugin = gitsigns-nvim;
type = "lua"; type = "lua";
config = "require('gitsigns').setup()"; config = fileContents ./plugins/gitsigns.lua;
} }
{ {
plugin = nvim-autopairs; plugin = nvim-autopairs;

View file

@ -0,0 +1,15 @@
local gitsigns = require("gitsigns")
local function visual_stage()
local first_line = vim.fn.line('v')
local last_line = vim.fn.getpos('.')[2]
gitsigns.stage_hunk({ first_line, last_line })
-- Switch back to normal mode, there may be a cleaner way to do this
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 't', false)
end
vim.keymap.set("v", "gbhs", function()
visual_stage()
end)
gitsigns.setup();