HarshK97
diffmantic.nvim
Lua

Semantic Diff Engine for Neovim Using Tree-sitter

Last updated Jun 12, 2026
122
Stars
0
Forks
1
Issues
0
Stars/day
Attention Score
61
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Diffmantic Logo

Semantic diff for Neovim using Tree-sitter. Understands code structure to detect moved functions, updated blocks, and real changes, not just line differences.

Demo

Features

  • 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
  • Rename detection โ€” Shows renamed variables and functions
  • Language agnostic โ€” Works with languages that have Tree-sitter parsers and diffmantic query support

Coming Soon: diffmantic CLI

A standalone Go CLI is in active development โ€” the same semantic diff engine, usable everywhere:

  • Terminal TUI โ€” Side-by-side diff viewer built with Bubble Tea
  • git difftool โ€” Drop-in replacement: git difftool -t diffmantic
  • Editor backends โ€” JSON output mode for Neovim and VS Code plugins
  • CI / scripts โ€” Unified diff format for piping and automation
The Neovim plugin will become a thin UI client that calls the CLI

Installation

Using lazy.nvim:

{
    "HarshK97/diffmantic.nvim",
    config = function()
        require("diffmantic").setup()
    end,
}

Usage

Compare two files:

:Diffmantic path/to/file1 path/to/file2

Compare current buffer with another file:

:Diffmantic path/to/other_file

How It Works

The current core follows a multi-phase AST matching pipeline:

  • Pre-match โ€” Seeds stable mappings from unchanged lines
  • Top-down matching โ€” Finds identical/high-confidence subtree pairs
  • Bottom-up matching โ€” Expands matches using mapped descendants
  • Recovery matching โ€” Iteratively recovers remaining valid mappings
  • Action generation + analysis โ€” Produces move/update/insert/delete actions and refined hunks

Requirements

  • Neovim 0.9+
  • Tree-sitter parser for the language you're diffing

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • GumTree repository:
  • GumTree paper: simplefinegrainedaccurateandscalablesourcedifferencing.pdf>
  • Beyond GumTree paper: BeyondGumTreeAHybridApproachtoGenerateEdit_Scripts>
๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท HarshK97/diffmantic.nvim ยท Updated daily from GitHub