Skip to content

HarshK97/diffmantic.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  • Language agnostic — Works with any language that has a Tree-sitter parser

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

Implements the GumTree algorithm for AST matching:

  1. Top-down matching — Finds identical subtrees by hash
  2. Bottom-up matching — Matches parents based on mapped children
  3. Recovery matching — LCS-based matching for remaining nodes

Requirements

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

License

MIT

About

Semantic Diff Engine for Neovim Using Tree-sitter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors