Merge pull request #11 from oug-t/feat/difi.nvim

feat: add difi.nvim support
This commit is contained in:
Tommy Guo 2026-01-31 14:01:43 -05:00 committed by GitHub
commit 0478c03f04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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") editor := os.Getenv("EDITOR")
if editor == "" { if editor == "" {
if _, err := exec.LookPath("nvim"); err == nil { 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 := exec.Command(editor, args...)
c.Stdin, c.Stdout, c.Stderr = os.Stdin, os.Stdout, os.Stderr 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 tea.ExecProcess(c, func(err error) tea.Msg {
return EditorFinishedMsg{Err: err} 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) line = git.CalculateFileLine(m.diffContent, 0)
} }
m.inputBuffer = "" 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 // Viewport trigger