Repository navigation
Conversation
The `diff_buf_read` and `diff_buf_win_enter` hooks only reported the window's layout position, so consumers such as statusline and winbar plugins had to walk Diffview internals to learn which revision a buffer shows. Extend the hook context with the buffer's revision (`type`, `commit`, `stage`, `tracks_head`), its repo-relative `path`, the repository `toplevel` and the `adapter` name. The `DiffviewDiffBufRead` and `DiffviewDiffBufWinEnter` User autocmds carry the same fields in `data`, together with `bufnr` and `winid`.
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.
The
diff_buf_readanddiff_buf_win_enterhooks only report the window's layout position (symbol,layout_name).This PR extends the hook context with:
rev:type("LOCAL","COMMIT","STAGE"or"CUSTOM"),commit,stageandtracks_headpath: the file path relative totopleveltoplevel: the repository rootadapter:"git","hg","jj"or"p4"(niloutside a repository)The
DiffviewDiffBufReadandDiffviewDiffBufWinEnterUser autocmds carry the same fields indata, together withbufnrandwinid. The existing fields are unchanged.This is especially useful for winbar and statusline plugins, which can now label each diff window with the revision it shows (
LOCAL,INDEX,HEAD, a commit hash) directly from the hook:A statusline component then reads
vim.w.diffview_ctxwhen it draws.