feat: add difi.nvim support

This commit is contained in:
Tommy Guo 2026-01-31 14:01:19 -05:00
parent 556b8984d3
commit 9648bf2d03
2 changed files with 8 additions and 2 deletions

View File

@ -55,7 +55,7 @@ func DiffCmd(targetBranch, path string) tea.Cmd {
}
}
func OpenEditorCmd(path string, lineNumber int) tea.Cmd {
func OpenEditorCmd(path string, lineNumber int, targetBranch string) tea.Cmd {
editor := os.Getenv("EDITOR")
if editor == "" {
if _, err := exec.LookPath("nvim"); err == nil {
@ -73,6 +73,11 @@ func OpenEditorCmd(path string, lineNumber int) tea.Cmd {
c := exec.Command(editor, args...)
c.Stdin, c.Stdout, c.Stderr = os.Stdin, os.Stdout, os.Stderr
// Pass the diff target branch to the editor via environment variable
// This enables plugins like difi.nvim to auto-configure the view
c.Env = append(os.Environ(), fmt.Sprintf("DIFI_TARGET=%s", targetBranch))
return tea.ExecProcess(c, func(err error) tea.Msg {
return EditorFinishedMsg{Err: err}
})

View File

@ -184,7 +184,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
line = git.CalculateFileLine(m.diffContent, 0)
}
m.inputBuffer = ""
return m, git.OpenEditorCmd(m.selectedPath, line)
// Integration Point: Pass targetBranch to the editor command
return m, git.OpenEditorCmd(m.selectedPath, line, m.targetBranch)
}
// Viewport trigger