Skip to content

feat(nvim): add tmux provider support for OpenCode plugin#128

Open
pablon wants to merge 2 commits intoGentleman-Programming:mainfrom
pablon:main
Open

feat(nvim): add tmux provider support for OpenCode plugin#128
pablon wants to merge 2 commits intoGentleman-Programming:mainfrom
pablon:main

Conversation

@pablon
Copy link

@pablon pablon commented Mar 7, 2026

Summary

  • Add automatic provider detection based on TMUX environment variable
    • Add tmux provider support for OpenCode plugin.
    • Use tmux provider inside tmux, otherwise fallback to snacks.

Provider Selection (Line 106)

local provider = vim.env.TMUX and "tmux" or "snacks"
  • Conditional logic: Checks if running inside tmux
  • If TMUX env var exists → use "tmux" provider
  • Otherwise → use "snacks" provider (snacks.nvim)

Provider Configuration (Lines 107-129)

TMUX Provider (Lines 110-116)

tmux = {
  win = {
    enter = true,             -- Enter the window
    position = "left",        -- Split on left side
  },
  focus = true,               -- Focus the pane when opening
  allow_passthrough = false,  -- Disable tmux passthrough mode
}

Snacks Provider (Lines 117-127)

snacks = {
  auto_close = true,          -- Close when done
  focus = true,               -- Focus the window
  win = {
    enter = true,             -- Enter the window
    position = "left",        -- Split on left side
    bo = {
      filetype = "opencode_terminal",  -- Custom filetype for syntax/behavior
    },
  },
}

Key Design Patterns

  1. Mode Consistency: All commands work in normal + visual modes except toggle (normal only)
  2. Auto-submit Pattern: Every command uses { submit = true } to skip confirmation
  3. Context Prefixes: Uses @this, @file to specify scope
  4. Environment Adaptation: Automatically chooses UI provider based on tmux presence
  5. Hierarchical Keybindings: <leader>a -> <leader>ap -> <leader>ap[e/f/d/r/t/o]

Workflow Example

  1. User presses <leader>ape on selected code
  2. OpenCode calls prompt("explain", { submit = true })
  3. Plugin opens in left split (snacks) or tmux pane
  4. AI explains the selected code
  5. Window auto-closes when done (auto_close = true)

PS: Aguante bigote!!! 👨🏻

pablon added 2 commits March 7, 2026 07:57
- Add automatic provider detection based on TMUX environment variable
- Configure tmux provider with window focus and passthrough settings
- Enhance snacks provider with auto_close and custom filetype
- Set provider.enabled dynamically (tmux when inside tmux, snacks otherwise)
- Configure tmux.allow_passthrough=false to prevent UI conflicts with nvim
- Add explicit window.enter=true for both providers
- Set filetype to 'opencode_terminal' for proper syntax highlighting

Signed-off-by: pablon <73798198+pablon@users.noreply.github.com>
Signed-off-by: pablon <73798198+pablon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant