Skip to content

feat(terminal): add focus_on_open option#271

Closed
zgs225 wants to merge 1 commit into
nickjvandyke:mainfrom
zgs225:main
Closed

feat(terminal): add focus_on_open option#271
zgs225 wants to merge 1 commit into
nickjvandyke:mainfrom
zgs225:main

Conversation

@zgs225
Copy link
Copy Markdown

@zgs225 zgs225 commented May 22, 2026

Tasks

Description

By default opencode.terminal.open() and toggle() return focus to the
previous window after opening. This adds a focus_on_open option that,
when true, keeps the cursor in the terminal and enters insert mode.
Affects three code paths: new terminal creation, re-showing a hidden
terminal, and the TermRequest redraw autocmd.

Fallback behavior is unchanged — omitting the option (or setting it
false/nil) preserves exactly the existing focus behavior.

Testing

  1. Set up vim.g.opencode_opts with focus_on_open = true in both
    server.start and server.toggle, and map require("opencode").toggle().
  2. Press the toggle keymap — verify the terminal opens with focus and
    is in insert mode (ready for input).
  3. Press the toggle keymap again — verify the terminal hides.
  4. Press the toggle keymap a third time — verify it re-shows with focus
    and insert mode.
  5. Remove focus_on_open = true and repeat — verify focus returns to
    the previous window (original behavior unchanged).

Related Issue(s)

N/A

Screenshots/Videos

N/A

@nickjvandyke
Copy link
Copy Markdown
Owner

Thanks for the idea and effort! Unfortunately I intend to keep terminal.lua as a minimal and opinionated convenience (and workarounds for embedded opencode quirks). Other terminal plugins support extensive customization, so I don't see a need to re-implement that and take on the maintenance burden.

Sorry!!

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.

2 participants