Add gitsigns via vim.pack, track the pack lockfile
Restores plugin management after the v0.12 config rewrite dropped the earlier `vim.pack.add` calls. Plugins now live in `config/plugins/`, one file per plugin, so adding the next is a single require. Sets `<leader>` to Space for the gitsigns hunk mappings, and pins 'signcolumn' open so git and diagnostic signs don't shift text. The lockfile moves into the repo and is symlinked by bootstrap.sh, as the vim.pack docs recommend, giving reproducible plugin revisions across machines and a rollback path via git. vim.pack writes it with a truncating open, so it follows the symlink rather than replacing it. Drops the orphaned nvim-tree entry, unreferenced since the rewrite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e1382f5c1f
commit
509b16f543
6 changed files with 72 additions and 0 deletions
55
neovim/config/plugins/gitsigns.lua
Normal file
55
neovim/config/plugins/gitsigns.lua
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
vim.pack.add({ 'https://github.com/lewis6991/gitsigns.nvim' })
|
||||
|
||||
require('gitsigns').setup({
|
||||
on_attach = function(bufnr)
|
||||
local gitsigns = require('gitsigns')
|
||||
|
||||
local function map(mode, lhs, rhs, desc)
|
||||
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
-- Navigation, falling back to vim's own diff motions in diff mode
|
||||
map('n', ']c', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({ ']c', bang = true })
|
||||
else
|
||||
gitsigns.nav_hunk('next')
|
||||
end
|
||||
end, 'Next git hunk')
|
||||
|
||||
map('n', '[c', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({ '[c', bang = true })
|
||||
else
|
||||
gitsigns.nav_hunk('prev')
|
||||
end
|
||||
end, 'Previous git hunk')
|
||||
|
||||
-- Actions
|
||||
map('n', '<leader>hs', gitsigns.stage_hunk, 'Stage hunk')
|
||||
map('n', '<leader>hr', gitsigns.reset_hunk, 'Reset hunk')
|
||||
|
||||
map('v', '<leader>hs', function()
|
||||
gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
||||
end, 'Stage selected hunk')
|
||||
|
||||
map('v', '<leader>hr', function()
|
||||
gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
||||
end, 'Reset selected hunk')
|
||||
|
||||
map('n', '<leader>hS', gitsigns.stage_buffer, 'Stage buffer')
|
||||
map('n', '<leader>hR', gitsigns.reset_buffer, 'Reset buffer')
|
||||
map('n', '<leader>hp', gitsigns.preview_hunk, 'Preview hunk')
|
||||
map('n', '<leader>hd', gitsigns.diffthis, 'Diff against index')
|
||||
|
||||
map('n', '<leader>hb', function()
|
||||
gitsigns.blame_line({ full = true })
|
||||
end, 'Blame line')
|
||||
|
||||
map('n', '<leader>hq', gitsigns.setqflist, 'Hunks to quickfix')
|
||||
|
||||
-- Toggles
|
||||
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, 'Toggle line blame')
|
||||
map('n', '<leader>td', gitsigns.toggle_deleted, 'Toggle deleted lines')
|
||||
end,
|
||||
})
|
||||
Loading…
Reference in a new issue