Status: Accepted
The editor needed a way to interact with Git without leaving the terminal session. Options considered:
| Option | Pros | Cons |
|---|---|---|
| LazyGit subprocess | Zero code for git logic; polished full TUI; actively maintained | Requires lazygit to be installed |
| Custom git panel (git2-rs) | No external dep | Months of work; inferior UX |
| Shell out to raw git | Simple | No interactive UI; output not TUI-friendly |
LazyGit already covers staging hunks, branch management, rebasing, stash, conflict resolution, and more. Building even a fraction of that in-editor would be a poor use of time and would always lag behind lazygit's quality.
Integrate via the suspend/resume subprocess pattern:
SPC g gfiresAction::GitOpen→Editor::open_lazygit()- The editor suspends its TUI:
disable_raw_mode()execute!(LeaveAlternateScreen)— restores the user's original terminalterminal.show_cursor()
std::process::Command::new("lazygit").status()spawns lazygit with inherited stdin/stdout/stderr — lazygit takes full control of the terminal.- When the user quits lazygit (
q), the process exits and we resume:enable_raw_mode()execute!(EnterAlternateScreen)— switches back to our alternate screenterminal.clear()— forces ratatui to repaint every cell (removes lazygit residue)
- Every open buffer that has a file path is reloaded from disk, because git operations (pull, checkout, rebase, apply patch) may have changed file content.
- Status message:
"Returned from lazygit"on success, or an error message if lazygit is not installed or crashes.
| Key | Action |
|---|---|
SPC g g |
Open lazygit |
The SPC g which-key group is reserved for future git commands (e.g. SPC g b for
blame, SPC g l for log) if needed.
If lazygit is not on $PATH, Command::new("lazygit") returns
ErrorKind::NotFound. The editor catches this and displays a friendly message:
lazygit not found — install it (e.g. brew install lazygit)
The TUI is always restored before showing the message so the editor remains usable.
Positive
- Full git TUI (stage/unstage hunks, commits, branches, rebase, stash, log, diff) for zero lines of git logic in forgiven.
- lazygit improvements (new features, bug fixes) are free.
- The suspend/resume pattern is well-established in terminal editors (Helix, Kakoune).
Negative / trade-offs
- Requires lazygit to be separately installed. Not bundled.
- No deep integration: forgiven is unaware of the current branch, dirty files, etc.
(These could be added later via
git2or a status-bargit rev-parsecall.) - On some terminal emulators the alternate-screen switch flickers briefly.