Semantic diff for Neovim using Tree-sitter. Understands code structure to detect moved functions, updated blocks, and real changes, not just line differences.
- Move detection — Knows when code blocks are moved, not deleted and re-added
- Update detection — Highlights modified code in place
- Insert/Delete detection — Shows new and removed code
- Language agnostic — Works with any language that has a Tree-sitter parser
Using lazy.nvim:
{
"HarshK97/diffmantic.nvim",
config = function()
require("diffmantic").setup()
end,
}Compare two files:
:Diffmantic path/to/file1 path/to/file2Compare current buffer with another file:
:Diffmantic path/to/other_fileImplements the GumTree algorithm for AST matching:
- Top-down matching — Finds identical subtrees by hash
- Bottom-up matching — Matches parents based on mapped children
- Recovery matching — LCS-based matching for remaining nodes
- Neovim 0.9+
- Tree-sitter parser for the language you're diffing
MIT
