A simple Neovim plugin that provides a convenient API over git's native diff functionality for viewing file history.
This is a hobby project for personal use - NOT production-ready!
- Experimental: Built for fun and personal workflow optimization
- Limited testing: Only tested on macOS with basic git repositories
- No warranty: Use at your own risk
- Performance: May be slow on files with extensive history
Feel free to use, modify, or learn from it, but don't expect production quality!
This plugin is essentially a convenient wrapper around git's native diff functionality. It provides a simple interface to:
- Browse git commit history for the current file
- Select any commit to diff against
- View the differences in Neovim's built-in diff mode
Think of it as running git log <file> and git show <commit>:<file> with a nice UI wrapper.
The plugin provides a floating popup window to browse and select commits from your file's history:
Once you select a commit, the plugin opens Neovim's native diff mode to compare the current file with the historical version:
If you're looking for more feature-rich git integration, consider these excellent alternatives:
- gitsigns.nvim - Comprehensive git decorations and hunk management with
:Gitsigns diffthis <revision> - diffview.nvim - Advanced diff viewer with file history browser (
:DiffviewFileHistory) - vim-fugitive - The definitive git plugin for Vim/Neovim with
:Glogand:0Gclog - neogit - Magit clone for Neovim with comprehensive git interface
- vim-gitgutter - Git diff markers in sign column with preview capabilities
These plugins offer more features, better performance, and are actively maintained by the community.
- View git commit history for the current file
- Interactive popup window with commit selection
- Diff current file (including unsaved changes) against any historical version
- Terminal color scheme support (cterm colors)
- Configurable pane layout
- Simple and focused - does one thing
- Neovim >= 0.7.0
- Git installed and accessible in PATH
- File must be in a git repository and tracked by git
Using lazy.nvim
{
'morass/history-git-diff.nvim',
config = function()
require('history-git-diff').setup({
-- Configuration options (see below)
})
end,
}Using vim-plug
Plug 'morass/history-git-diff.nvim'Then in your init.vim:
lua require('history-git-diff').setup()Using packer.nvim
use {
'morass/history-git-diff.nvim',
config = function()
require('history-git-diff').setup()
end
}Clone the repository:
git clone https://github.com/morass/history-git-diff.nvim ~/.local/share/nvim/site/pack/plugins/start/history-git-diff.nvimThen setup in lua:
require('history-git-diff').setup()require('history-git-diff').setup({
swap_panes = false, -- Set to true to swap pane positions
})If you prefer to configure from Vimscript (e.g., in your init.vim):
" Set configuration before calling setup
let g:history_git_diff_config = {'swap_panes': v:true}
" Then call setup
lua require('history-git-diff').setup(vim.g.history_git_diff_config)Or inline:
" Swap panes directly in setup call
lua require('history-git-diff').setup({ swap_panes = true })swap_panes(boolean, default:false)false: Current file on LEFT (editable), Historical version on RIGHT (read-only)true: Historical version on LEFT (read-only), Current file on RIGHT (editable)
- Open any file that's tracked by git
- Run
:DiffHistorycommand - Navigate commits with
j/k - Press
Enterto view diff with selected commit - Press
ESCorqto cancel
j/k- Navigate through commitsEnter- Open diff view with selected commitESC/q- Close popup and cancel
The diff view opens in a new tab with:
- Default layout (
swap_panes = false):- Left pane: Current file (editable, includes unsaved changes)
- Right pane: Historical version (read-only)
- Swapped layout (
swap_panes = true):- Left pane: Historical version (read-only)
- Right pane: Current file (editable, includes unsaved changes)
Close the tab when done to return to your work.
Under the hood, this plugin simply:
- Runs
git logto get commit history for current file - Shows commits in a floating window
- When selected, runs
git show <commit>:<file>to get historical version - Opens Neovim's diff mode to compare versions
It's essentially a UI wrapper around basic git commands.
- Only shows commits from current branch (by design)
- Limited to 100 most recent commits
- Requires file to be tracked by git
- No support for renamed/moved files history
- Simple terminal colors only (no fancy theming)
Uses terminal colors (cterm) for consistency:
- Blue: Commit hashes
- Gray: Help text and dates
- Red: Cancel option
- White: Commit messages
"Not in a git repository": Make sure you're in a git repo (git status should work)
"File is not tracked by git": The file needs to be added to git (git add <file>)
No commits found: The file might be newly added with no commit history yet
Colors look wrong: The plugin uses terminal colors - appearance depends on your terminal theme
Do whatever you want with it. No warranties, no support, just a fun little tool.
Remember: This is a hobby project. It might break, it might have bugs, but it gets the job done (usually).

