feat(ui): make <C-w>o work inside opencode windows#327
Open
jugarpeupv wants to merge 14 commits intosudo-tee:mainfrom
Open
feat(ui): make <C-w>o work inside opencode windows#327jugarpeupv wants to merge 14 commits intosudo-tee:mainfrom
jugarpeupv wants to merge 14 commits intosudo-tee:mainfrom
Conversation
Allow users to customize window-local options for the input window via `ui.input.win_options` in config. Any valid Neovim window option can be set, such as signcolumn, cursorline, number, relativenumber, etc. This improves flexibility for user preferences and editor appearance.
Adds a new command and API to insert the current visual selection as a formatted code block directly into the input buffer. This includes a new `add_visual_selection_inline` function, a corresponding keymap, and a helper to build the formatted text. Unit tests are provided to ensure correct formatting and error handling for edge cases.
Move winfixbuf handling for input and output windows to a shared `buf_fix_win.fix_to_win` utility. This reduces duplication and ensures consistent buffer-to-window pinning logic. Also removes redundant winfixbuf resets and last-window buffer swap logic from ui.lua, as this is now handled in a single place.
Update the inline visual selection text to use bolded file path formatting (**`path/to/file`**) instead of the previous "Here is some code from" prefix. Adjust unit tests to match the new output format. This change makes the inserted context more visually distinct and concise.
Add new action `add_visual_selection_inline` with keymap `<leader>oY` to insert visually selected code directly into the input buffer as a Markdown code block, prefixed with the file path. Updates documentation with usage details and example. Leaves cursor in normal mode for prompt editing.
Add a warning notification when a part update references a message that cannot be found in the render state. This helps with debugging and improves visibility into potential state inconsistencies.
Store the ratio of the output window's width to the total columns when hiding windows, unless the UI position is 'current'. This enables restoring window sizes more accurately.
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description:
Pressing
<C-w>owhile inside an opencode window previously had no effect or caused errors because Neovim's built-in "close all other windows" command does not know about opencode's window pair. This PR makes it work correctly.It is in fact useful to have two buffers in the chat (1 por the user input and 1 for the output) so the only thing i am missing is the ability to
<c-w>oin it@sudo-tee if you find another implementation better, i am up for it, this one at least is working for me
What changed
<C-w>osupport (autocmds.lua,state.lua)Buffer-local keymaps for
<C-w>o/<C-w><C-o>are set on both opencode buffers. The handler closes all non-floating windows that are not part of the opencode pair (input + output + footer), preserving the opencode layout intact. The saved window-width ratio is also cleared so the nexttoggleopens at the configured default width rather than the now-meaningless pre-<C-w>owidth.A new
are_opencode_only_windows()helper instate.luadetects when opencode is the only thing left on screen (i.e. after<C-w>owas used). This is wired into the toggle-action rule table so that pressing the toggle key after<C-w>ocorrectly hides opencode instead of trying to re-open it.Replace
winfixbufwithbuf_fix_win(input_window.lua,output_window.lua,ui.lua)winfixbuf = truewas set on the opencode windows to prevent other code from redirecting their buffer. However this is a hard lock: any plugin or Neovim feature that tries to switch a buffer in a window (pickers like snacks.nvim/telescope,:buffer, etc.) will crash with:The codebase already contained
buf_fix_win.lua— an autocmd-based module that closes any duplicate window that shows an opencode buffer — but it was never wired up. This PR activates it as the replacement:winfixbuf = trueis removed from bothinput_window.setup()andoutput_window.setup()buf_fix_win.fix_to_win()is called for each buffer, achieving the same "this buffer stays in its intended window" guarantee without the hard lock that breaks pickerswinfixbuf = falseunset calls inui.luaare removed