feat(api): add public inline diff rendering API#345
Open
fredrikaverpil wants to merge 1 commit intoesmuellert:mainfrom
Open
feat(api): add public inline diff rendering API#345fredrikaverpil wants to merge 1 commit intoesmuellert:mainfrom
fredrikaverpil wants to merge 1 commit intoesmuellert:mainfrom
Conversation
5d2a86a to
93ffcd7
Compare
9926092 to
209cd38
Compare
Expose codediff's inline diff rendering as a reusable Lua API for both standalone use and plugin consumers (e.g. gitsigns.nvim). Low-level API (re-exports, no state): - codediff.diff() — pure diff computation - codediff.render_inline_diff() — render on any buffer - codediff.clear_inline_diff() — clear decorations High-level API (standalone with git integration): - codediff.render_inline() — toggle inline diff per-buffer or globally - codediff.change_base() — change base revision for comparison
209cd38 to
f5f7731
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
I'd like the codediff.nvim experience in regular buffers where there are git diffs.
Also, the gitsigns.nvim community has requested Zed-style inline diff rendering (gitsigns#899). codediff already has the hard parts solved — C diff engine, virtual line rendering with treesitter syntax highlighting, character-level diff coloring — but none of it is accessible as a public API.
What
Add 5 public Lua API functions to
require("codediff"):diff(original_lines, modified_lines, opts){ changes, moves, hit_timeout }render_inline_diff(bufnr, diff_result, original_lines, modified_lines, opts)clear_inline_diff(bufnr)render_inline(show, global)change_base(base, global)"HEAD",":0"), re-renders active buffersNotes
HEAD(git index) (not the:0, which is the gitsigns convention)codediff.setup()— highlights are initialized lazily on first render:CodeDiffsessions