Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/adrs/005.tabs-vim.ecosystem-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 005. Ecosystem Support — FlogInTab and Ecosystem Buffer Close

**SPEC:** ecosystem-support
**Status:** Accepted
**Last Updated:** 2026-04-05

---

## Decision

Add two ecosystem integration features to `plugin/tabs.vim`:

1. **`TabsVim_FlogInTab()`** — opens vim-flog's full-repo git log in a new tab via `Flogsplit -open-cmd=tabedit -all`. Guards with `exists(':Flogsplit')` and emits a warning if vim-flog is not loaded. Exposed as a `TabsVim_*` function (rather than a vimrc one-liner) for the same discoverability reason as `TabsVim_FzfOpenInTab()` — users exploring the API should not need to inspect vim-flog's command syntax.

2. **`g:tabs_vim_tabclose_types` autocmd** — reads a user-supplied list of tokens at plugin load time and installs buffer-local `q` → `:tabclose` mappings for matching filetypes or conditions. Default is empty (no OOTB behavior). Supported tokens: `'floggraph'`, `'git'`, `'diff'`; any other string is treated as a `FileType` name.

---

## Context

Users who open ecosystem tool outputs (flog graph, fugitive commit view, vimdiff) in tabs consistently need two things:

1. A single command to open the tool in a new tab (the same pattern `TabsVim_FzfOpenInTab()` already established for fzf).
2. A `q` binding to close the whole tab when done — the "modal overlay" mental model.

Without plugin support, users must write three separate augroups in their vimrc, each guarding a different filetype or buffer condition. This is boilerplate that belongs in the plugin because:
- It is tab-scoped behavior (`:tabclose`, not `:q` or `:close`)
- The same pattern repeats identically for every ecosystem tool
- It is discoverable — users looking for tab integrations will find it here

The `diff` condition (`WinEnter` + `&diff`) requires special handling (not a FileType) but is common enough to be a first-class supported token.

---

## Considered Options

| Option | Pros | Cons |
|--------|------|------|
| **`g:tabs_vim_tabclose_types` list, default empty** *(chosen)* | Opt-in; consistent with ADR-004 (no OOTB bindings); name reflects buffer types not just filetypes | Requires one vimrc line to activate |
| Always-on autocmd for hardcoded filetypes | Zero config | Imposes behavior on users who manage their own `q` bindings for these tools |
| No autocmd; document pattern in key-binding.md | Zero plugin complexity | Users copy the same boilerplate repeatedly; no discoverability |
| Per-tool boolean flags (`g:tabs_vim_flog_close`, etc.) | Granular opt-in | Proliferates config variables for a single repeated pattern |

The list-based approach keeps one config axis while remaining extensible. Any filetype string works, so users with tools not listed here (e.g. `'fugitiveblame'`, `'GV'`) can add them without plugin changes.

---

## Consequences

- `TabsVim_FlogInTab()` is added to the Public Function API in `key-binding.md` under a new "Git Integration" section.
- `g:tabs_vim_tabclose_types` is documented in both `ecosystem-support.md` and the recommended vimrc block in `key-binding.md`.
- The plugin continues to install zero OOTB keybindings (ADR-004 is not affected); the autocmd only fires if the user sets `g:tabs_vim_tabclose_types`.
- Users with existing manual augroups for `q` → `:tabclose` can migrate to the config or leave their vimrc unchanged — both work.
- `diff` handling uses `WinEnter` + `&diff` guard (matching the existing vimrc pattern) rather than a filetype, since vimdiff buffers don't have a dedicated filetype.
78 changes: 78 additions & 0 deletions docs/specs/ecosystem-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SPEC: Ecosystem Support

**Last Updated:** 2026-04-05

---

## Description

Defines tab-aware integration functions for common Vim ecosystem plugins. The plugin already exposes `TabsVim_FzfOpenInTab()` for fzf. This spec extends that pattern to cover vim-flog (git log viewer) and establishes a configurable autocmd for binding `q` → `:tabclose` in ecosystem tool buffers (flog graph, fugitive, vimdiff).

The common workflow: open a tool's output in a dedicated tab, then press `q` to close the whole tab when done — the same mental model as a modal overlay. Without plugin support, users must replicate three separate augroups across their vimrc.

**Persona:** Vim/Neovim users with fzf, vim-flog, and/or vim-fugitive in their setup who open those tools' outputs in tabs.

---

## Features

| Feature | Description | ADR | Done? |
|---------|-------------|-----|-------|
| **`TabsVim_FlogInTab()`** | Open vim-flog git log in a new tab (`Flogsplit -open-cmd=tabedit -all`) | ADR-005 | ⬜ |
| **Ecosystem buffer close** | `g:tabs_vim_tabclose_types` list: buffer types/conditions that get `q` → `:tabclose` auto-wired | ADR-005 | ⬜ |

---

## Public Function API

### Git Integration

| Function | Description |
|----------|-------------|
| `TabsVim_FlogInTab()` | Open vim-flog full-repo git log in a new tab (requires vim-flog) |

### Ecosystem Buffer Close

No function — controlled by config only (see below).

---

## Configuration

### `g:tabs_vim_tabclose_types`

A list of buffer type tokens. For each entry the plugin installs a buffer-local `q` → `:tabclose` mapping. Default is empty (no OOTB behavior).

```vim
" opt-in example — must be set before the plugin loads (i.e. before plug#end())
let g:tabs_vim_tabclose_types = ['floggraph', 'git', 'diff']
```
Comment thread
jesse23 marked this conversation as resolved.

Supported entry values:

| Value | Trigger condition | Typical source |
|-------|-------------------|----------------|
| `'floggraph'` | `FileType floggraph` | vim-flog graph buffer |
| `'git'` | `FileType git` | vim-fugitive commit/status buffer |
| `'diff'` | `WinEnter` with `&diff` set | vimdiff / `Gdiffsplit` |

Users may pass any valid `FileType` name to cover other tools (e.g. `'fugitiveblame'`).

---

## Recommended vimrc Wiring

```vim
" ── Git log ──────────────────────────────────────────────────────────────────
nnoremap <silent> <leader>gg :call TabsVim_FlogInTab()<CR>

" ── Ecosystem buffer close (q → :tabclose) ───────────────────────────────────
let g:tabs_vim_tabclose_types = ['floggraph', 'git', 'diff']
```

---

## Related

- [key-binding.md](key-binding.md) — full public function API and vimrc wiring reference
- ADR-005 — decision record for this spec
14 changes: 14 additions & 0 deletions docs/specs/key-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Only operations with real logic are exposed as `TabsVim_*` functions. Simple one
|----------|-------------|
| `TabsVim_FzfOpenInTab()` | Open fzf file picker with `tabedit` as the sink (requires fzf.vim) |

### Git Integration

| Function | Description |
|----------|-------------|
| `TabsVim_FlogInTab()` | Open vim-flog full-repo git log in a new tab (requires vim-flog) |

---

## Recommended vimrc Wiring
Expand Down Expand Up @@ -80,6 +86,13 @@ nnoremap <silent> <leader>tt :call TabsVim_NewTabTerm()<CR>
nnoremap <silent> gF :tabedit <cfile><CR>
nnoremap <silent> <leader>fy :let @+ = expand("%:p")<CR>
nnoremap <silent> <leader>ft :call TabsVim_FzfOpenInTab()<CR>

" ── Git log ───────────────────────────────────────────────────────────────────
nnoremap <silent> <leader>gg :call TabsVim_FlogInTab()<CR>

" ── Ecosystem buffer close (q → :tabclose) ───────────────────────────────────
" Must be set before plug#end() — read once at plugin load time.
let g:tabs_vim_tabclose_types = ['floggraph', 'git', 'diff']
```

---
Expand Down Expand Up @@ -127,3 +140,4 @@ In normal mode, `<C-]>` is the native "jump to tag under cursor" (ctags / cscope
| **No OOTB keybindings** | Plugin installs zero keymaps; mouse DnD infrastructure only | ADR-004 | ✅ |
| **Public function API** | All operations promoted to `TabsVim_*` public functions | ADR-004 | ✅ |
| **Example vimrc block** | Ready-made mapping block for users to copy into vimrc | — | ✅ |
| **Ecosystem integrations** | `TabsVim_FlogInTab()` and `g:tabs_vim_tabclose_types` config | ADR-005 | ⬜ |
1 change: 1 addition & 0 deletions docs/specs/tabs.vim.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ let g:tabs_vim_colors = {
## Related Specs

- [key-binding.md](key-binding.md) — public `TabsVim_*` function API, OOTB behavior contract, and recommended vimrc wiring
- [ecosystem-support.md](ecosystem-support.md) — tab-aware integrations for fzf, vim-flog, vim-fugitive, and vimdiff

---

Expand Down
Loading
Loading