feat: add open_diff, open_readonly, and readonly open_file plugin APIs - #438
Open
eugenioenko wants to merge 2 commits into
Open
feat: add open_diff, open_readonly, and readonly open_file plugin APIs#438eugenioenko wants to merge 2 commits into
eugenioenko wants to merge 2 commits into
Conversation
Expose three new Lua plugin APIs for the git history plugin: - ttt.open_diff(title, old_lines, new_lines, file_path) — opens a native styled diff tab using the existing DiffViewWidget - ttt.open_readonly(title, lines, file_path) — opens a buffer tab with content provided directly, in readonly mode - ttt.open_file(path, line, readonly) — extended with optional third argument to open files in readonly mode Readonly tabs block all mutations (typing, enter, backspace, delete, tab/backtab) and refuse to save. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These APIs open read-only tabs, same as open_file — no permission needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
ttt.open_diff(title, old_lines, new_lines, file_path)Lua API — opens a native styled diff tab using the existingDiffViewWidget, enabling plugins to render side-by-side diffs from arbitrary content (e.g. git commit diffs)ttt.open_readonly(title, lines, file_path)Lua API — opens a readonly buffer tab with content provided directly, with syntax highlighting based onfile_pathextension (e.g. viewing a file at a specific git commit)ttt.open_file(path, line, readonly)with optional third boolean argument for readonly modeReadOnlyflag toeditorTabandEditorPaneWidgetthat blocks all mutations (typing, enter, backspace, delete, tab/backtab) and refuses to saveopen_diffandopen_readonlyrequirepanel.editorpermissionThese are the core primitives needed for a git-history plugin to show per-file commit history with native diff rendering and historical file viewing.
Test plan
TestOpenDiff,TestOpenBufferReadOnly,TestOpenFileReadOnly,TestOpenBufferReadOnlyReuseTabopen_diffopens diff tab,open_readonlyopens readonly tab, readonly blocks typing,open_filewith readonly flaggo test ./...)🤖 Generated with Claude Code