A Neovim plugin that analyzes git changes in your repository and populates the quickfix list with individual git hunks.
- =
Parses
git diffoutput to extract hunks - =� Populates quickfix list with proper formatting
- � Lazy-loaded for minimal startup impact
- =' Configurable via
vim.gvariables - =� LuaCATS type annotations for better IDE support
- <� No
setup()function required - works out of the box
Using lazy.nvim
{
'yourusername/chchchanges.nvim',
cmd = 'ChChanges', -- Lazy load on command
keys = {
{ '<leader>gc', '<cmd>ChChanges<cr>', desc = 'Show git changes' },
},
}Using packer.nvim
use {
'yourusername/chchchanges.nvim',
cmd = 'ChChanges',
}Using vim-plug
Plug 'yourusername/chchchanges.nvim':ChChanges- Populate quickfix with git hunks and open the quickfix window:ChChanges!- Populate quickfix with git hunks without opening the window
-- Show git changes in quickfix
vim.keymap.set('n', '<leader>gc', '<cmd>ChChanges<cr>', { desc = 'Show git changes' })
-- Load git changes without opening quickfix
vim.keymap.set('n', '<leader>gC', '<cmd>ChChanges!<cr>', { desc = 'Load git changes' })-- Populate and open quickfix
require('chchchanges').populate_quickfix()
-- Populate without opening
require('chchchanges').populate_quickfix({ open = false })
-- Append to existing quickfix list
require('chchchanges').populate_quickfix({ action = 'a' })Configuration is done via vim.g variables. No setup() function is required.
-- Custom git command (default: 'git')
vim.g.chchchanges_git_cmd = '/usr/local/bin/git'
-- Additional git diff arguments (default: {})
vim.g.chchchanges_diff_args = { '--cached' } -- Show staged changes only-- Show only staged changes
vim.g.chchchanges_diff_args = { '--cached' }
-- Show changes with more context
vim.g.chchchanges_diff_args = { '-U5' }
-- Compare against a specific branch
vim.g.chchchanges_diff_args = { 'main' }- Runs
git diffin the current repository (unstaged changes by default) - Parses the diff output to extract hunk headers (
@@ ... @@) - Creates quickfix entries for each hunk with:
- File path
- Line number where the hunk starts
- Context (function/class name if available)
- Populates the quickfix list with proper formatting
The plugin supports all git diff prefix formats (a/b, i/w, etc.) including mnemonic prefixes.
If you're experiencing issues with hunks not being detected, use the debug command:
:ChChangesDebugThis will open a split window showing the raw git diff output that the plugin is processing.
This plugin follows the Neovim Lua plugin best practices:
- � LuaCATS type annotations
- � No mandatory
setup()function - � Lazy initialization via
plugin/directory - � Configuration via
vim.gglobal variables - � Proper quickfix formatting
# Run automated tests
make test
# Setup manual test environment (creates test_file.lua with changes)
make manual-test
# Clean up test files
make cleanOr run tests directly:
# Automated tests
nvim --headless -c "luafile tests/parse_spec.lua" -c "qa!"
# Manual test
./tests/manual_test.shMIT
Contributions are welcome! Please feel free to submit a Pull Request.