neovim nvim embedded terminal support request #324

Open
opened 2026-02-16 17:26:13 -05:00 by yindo · 21 comments
Owner

Originally created by @robcmills on GitHub (Jun 27, 2025).

Originally assigned to: @adamdotdevin on GitHub.

I tried to run opencode inside a neovim embedded terminal buffer. Results were not great.

  • whole layout severely broken
  • header appeared to be off-screen above
  • every other line appeared to be blank, maybe some kind of text wrapping bug
  • I could not focus the primary prompt input correctly, insert mode was putting characters into the buffer below the input

Image

Image

Image

Originally created by @robcmills on GitHub (Jun 27, 2025). Originally assigned to: @adamdotdevin on GitHub. I tried to run opencode inside a neovim embedded terminal buffer. Results were not great. - whole layout severely broken - header appeared to be off-screen above - every other line appeared to be blank, maybe some kind of text wrapping bug - I could not focus the primary prompt input correctly, insert mode was putting characters into the buffer below the input ![Image](https://github.com/user-attachments/assets/afd632bd-8d2c-44e6-9e48-1dc9a76c7231) ![Image](https://github.com/user-attachments/assets/a67df1f6-0808-40f0-a4b2-1f7981c24f59) ![Image](https://github.com/user-attachments/assets/23b8573c-4966-40e7-a4b8-30947924e408)
Author
Owner

@Hippo0o commented on GitHub (Jun 30, 2025):

setting the theme to system seems to fix this issue for me.

@Hippo0o commented on GitHub (Jun 30, 2025): setting the theme to `system` seems to fix this issue for me.
Author
Owner

@kbnopro commented on GitHub (Jul 6, 2025):

I encountered the same issue, but not as severe.
When trying to run opencode in floating terminal (toggleterm.nvim), the layout seems to be shifted up a bit:

Image

After some investication and comparison with lazygit (which works correctly), it seems that the bottom bar is overflowing because opencode read the width of the current app, not the terminal itself.

@kbnopro commented on GitHub (Jul 6, 2025): I encountered the same issue, but not as severe. When trying to run opencode in floating terminal (toggleterm.nvim), the layout seems to be shifted up a bit: <img width="1684" height="1015" alt="Image" src="https://github.com/user-attachments/assets/a5c3a58e-8b00-483e-a64d-5d800e564c8f" /> After some investication and comparison with lazygit (which works correctly), it seems that the bottom bar is overflowing because opencode read the width of the current app, not the terminal itself.
Author
Owner

@nickjvandyke commented on GitHub (Jul 14, 2025):

setting the theme to system seems to fix this issue for me.

Initially this didn't work for me, but after upgrading to v0.3.5, it looks correct so far! Other themes still get messy but not a big deal.

Image
@nickjvandyke commented on GitHub (Jul 14, 2025): > setting the theme to system seems to fix this issue for me. Initially this didn't work for me, but after upgrading to `v0.3.5`, it looks correct so far! Other themes still get messy but not a big deal. <img width="1562" height="1010" alt="Image" src="https://github.com/user-attachments/assets/4fa3b8bf-d9da-40ff-bc1c-520a0ce47203" />
Author
Owner

@adamdotdevin commented on GitHub (Jul 14, 2025):

i think someone was working on an opencode.nvim plugin, too, which will be another solution

@adamdotdevin commented on GitHub (Jul 14, 2025): i think someone was working on an opencode.nvim plugin, too, which will be another solution
Author
Owner

@nickjvandyke commented on GitHub (Jul 14, 2025):

@adamdotdevin that might be me haha https://github.com/NickvanDyke/opencode.nvim

It's affected by this bug, unless I'm missing some way to work around it.

Related, it'd be helpful to expose a --theme CLI option so I can default to 'system' in the plugin rather than instruct users to manually modify their opencode config 😀

@nickjvandyke commented on GitHub (Jul 14, 2025): @adamdotdevin that might be me haha https://github.com/NickvanDyke/opencode.nvim It's affected by this bug, unless I'm missing some way to work around it. Related, it'd be helpful to expose a `--theme` CLI option so I can default to 'system' in the plugin rather than instruct users to manually modify their opencode config 😀
Author
Owner

@adamdotdevin commented on GitHub (Jul 14, 2025):

@adamdotdevin that might be me haha https://github.com/NickvanDyke/opencode.nvim

It's affected by this bug, unless I'm missing some way to work around it.

Related, it'd be helpful to expose a --theme CLI option so I can default to 'system' in the plugin rather than instruct users to manually modify their opencode config 😀

will add this flag

@adamdotdevin commented on GitHub (Jul 14, 2025): > @adamdotdevin that might be me haha https://github.com/NickvanDyke/opencode.nvim > > It's affected by this bug, unless I'm missing some way to work around it. > > Related, it'd be helpful to expose a `--theme` CLI option so I can default to 'system' in the plugin rather than instruct users to manually modify their opencode config 😀 will add this flag
Author
Owner

@kbnopro commented on GitHub (Jul 14, 2025):

Just want to let you guys know the new version 0.3.5 is now working for me when setting theme to system

@kbnopro commented on GitHub (Jul 14, 2025): Just want to let you guys know the new version `0.3.5` is now working for me when setting theme to `system`
Author
Owner

@nickjvandyke commented on GitHub (Jul 15, 2025):

oops, I just noticed there is also https://github.com/sudo-tee/opencode.nvim - did not mean to steal any thunder 😀

It seems to work around this limitation by making its own UI over opencode run

@nickjvandyke commented on GitHub (Jul 15, 2025): oops, I just noticed there is also https://github.com/sudo-tee/opencode.nvim - did not mean to steal any thunder 😀 It seems to work around this limitation by making its own UI over `opencode run`
Author
Owner

@geekmdtravis commented on GitHub (Jul 15, 2025):

I was having the same issue. Using ghostty, on macOS, with Neovim running the TokyoNight theme.

Image

I can confirm that the problem resolves by setting the theme to system, which is a reasonable workaround for now.

Image
@geekmdtravis commented on GitHub (Jul 15, 2025): I was having the same issue. Using `ghostty`, on macOS, with Neovim running the TokyoNight theme. <img width="1925" height="985" alt="Image" src="https://github.com/user-attachments/assets/ef9a133f-1b27-4ca5-a262-43e250da94dd" /> I can confirm that the problem resolves by setting the theme to system, which is a reasonable workaround for now. <img width="2311" height="1228" alt="Image" src="https://github.com/user-attachments/assets/a246a294-bc87-4cb0-86c3-947ac6cdbae2" />
Author
Owner

@nickjvandyke commented on GitHub (Jul 22, 2025):

will add this flag

I just migrated https://github.com/NickvanDyke/opencode.nvim to call opencode's server API rather than send text to the necessarily embedded TUI, so --theme is now much lower priority from my perspective 🙂

@nickjvandyke commented on GitHub (Jul 22, 2025): > will add this flag I just migrated https://github.com/NickvanDyke/opencode.nvim to call opencode's server API rather than send text to the necessarily embedded TUI, so `--theme` is now much lower priority from my perspective 🙂
Author
Owner

@robcmills commented on GitHub (Jul 23, 2025):

Update:

Thanks to Hippo0o for suggesting switching to system theme which did improve things for me.

However, it appears I am unable to scroll back/up to see the full session output?

Image

Maybe this is a personal config issue? Any ideas?

@robcmills commented on GitHub (Jul 23, 2025): Update: Thanks to [Hippo0o](https://github.com/Hippo0o) for suggesting switching to `system` theme which did improve things for me. However, it appears I am unable to scroll back/up to see the full session output? <img width="3456" height="2234" alt="Image" src="https://github.com/user-attachments/assets/612ea675-51e3-4e0d-998b-d7ff891ab3f1" /> Maybe this is a personal config issue? Any ideas?
Author
Owner

@nickjvandyke commented on GitHub (Jul 23, 2025):

@robcmills it looks like you're in Normal mode - you have to be in Terminal mode (Insert mode, essentially) to send inputs like scrolling to the TUI

@nickjvandyke commented on GitHub (Jul 23, 2025): @robcmills it looks like you're in Normal mode - you have to be in Terminal mode (Insert mode, essentially) to send inputs like scrolling to the TUI
Author
Owner

@robcmills commented on GitHub (Jul 23, 2025):

@NickvanDyke thanks for responding. I see. I guess this is a result of fundamental design/architecture decisions with regard to the TUI.

I was comparing it to Claude Code, which appears to just output to stdout in the terminal, sequentially appending. Whereas Opencode is rendering "fullscreen" and scrolling has to be accomplished through opencode, by sending keybindings that do not conflict with the environment, whether that is the parent terminal itself, or in this case neovim. Is this an accurate assessment?

This is somewhat disappointing to me, because the primary reason I use embedded terminal buffers in neovim is so that I can hit escape to switch to normal mode, and navigate terminal output the same way I navigate normal buffer contents, with all the same keybindings I am accustomed to in neovim, e.g. gg to go to start of session, G to go to bottom, navigating to specific lines, marks, etc.

I wonder if this is something worth accommodating for in opencode? Or am I just ignorant of the justifications for these choices?

Maybe offer some sort of configuration layout option, that is either "fullscreen" (current layout) or "append" (more like Claude Code, in that output is just appended to stdout)?

That could be one way to address/workaround this issue, as well as a whole class of other TUI layout bugs...

@robcmills commented on GitHub (Jul 23, 2025): @NickvanDyke thanks for responding. I see. I guess this is a result of fundamental design/architecture decisions with regard to the TUI. I was comparing it to Claude Code, which appears to just output to stdout in the terminal, sequentially appending. Whereas Opencode is rendering "fullscreen" and scrolling has to be accomplished _through opencode,_ by sending keybindings _that do not conflict with the environment,_ whether that is the parent terminal itself, or in this case neovim. Is this an accurate assessment? This is somewhat disappointing to me, because the primary reason I use embedded terminal buffers in neovim is so that I can hit escape to switch to normal mode, and navigate terminal output the same way I navigate normal buffer contents, with all the same keybindings I am accustomed to in neovim, e.g. `gg` to go to start of session, `G` to go to bottom, navigating to specific lines, marks, etc. I wonder if this is something worth accommodating for in opencode? Or am I just ignorant of the justifications for these choices? Maybe offer some sort of configuration _layout_ option, that is either "fullscreen" (current layout) or "append" (more like Claude Code, in that output is just appended to stdout)? That could be one way to address/workaround this issue, as well as a whole class of other TUI layout bugs...
Author
Owner

@blaadje commented on GitHub (Aug 26, 2025):

This is somewhat disappointing to me, because the primary reason I use embedded terminal buffers in neovim is so that I can hit escape to switch to normal mode, and navigate terminal output the same way I navigate normal buffer contents, with all the same keybindings I am accustomed to in neovim, e.g. gg to go to start of session, G to go to bottom, navigating to specific lines, marks, etc.

I agree 💯

@blaadje commented on GitHub (Aug 26, 2025): > This is somewhat disappointing to me, because the primary reason I use embedded terminal buffers in neovim is so that I can hit escape to switch to normal mode, and navigate terminal output the same way I navigate normal buffer contents, with all the same keybindings I am accustomed to in neovim, e.g. gg to go to start of session, G to go to bottom, navigating to specific lines, marks, etc. I agree 💯
Author
Owner

@blaadje commented on GitHub (Sep 10, 2025):

@adamdotdevin (sorry to ping), any thought on that ☝️ ?

@blaadje commented on GitHub (Sep 10, 2025): @adamdotdevin (sorry to ping), any thought on that ☝️ ?
Author
Owner

@uloco commented on GitHub (Sep 11, 2025):

I also cannot use shift+enter for linebreaks in the embedded terminal. Does anybody else have this issue?

@uloco commented on GitHub (Sep 11, 2025): I also cannot use shift+enter for linebreaks in the embedded terminal. Does anybody else have this issue?
Author
Owner

@Hippo0o commented on GitHub (Sep 11, 2025):

@uloco i had the same issue. I solved it by binding: tnoremap <S-CR> <M-CR>/vim.keymap.set("t", "<S-CR>", "<M-CR>") and binding alt+enter in opencode.

Depending on your terminal you might have to make S-CR work in vim/neovim first tho.

In alacritty i needed:

[[keyboard.bindings]]
chars = "\u001B[13;2u"
key = "Return"
mods = "Shift"

hope it helps.

@Hippo0o commented on GitHub (Sep 11, 2025): @uloco i had the same issue. I solved it by binding: `tnoremap <S-CR> <M-CR>`/`vim.keymap.set("t", "<S-CR>", "<M-CR>")` and binding `alt+enter` in opencode. Depending on your terminal you might have to make S-CR work in vim/neovim first tho. In alacritty i needed: ```toml [[keyboard.bindings]] chars = "\u001B[13;2u" key = "Return" mods = "Shift" ``` hope it helps.
Author
Owner

@Muizzyranking commented on GitHub (Nov 2, 2025):

I just installed opencode and the system theme does not come installed, do i have to install it separately??

@Muizzyranking commented on GitHub (Nov 2, 2025): I just installed opencode and the system theme does not come installed, do i have to install it separately??
Author
Owner

@rekram1-node commented on GitHub (Nov 2, 2025):

@Muizzyranking https://github.com/sst/opencode/issues/3688 we are gonna fix that, we just shipped v1 and it has some behavior changes

@rekram1-node commented on GitHub (Nov 2, 2025): @Muizzyranking https://github.com/sst/opencode/issues/3688 we are gonna fix that, we just shipped v1 and it has some behavior changes
Author
Owner

@garrett-hopper commented on GitHub (Nov 9, 2025):

Seems like nvim terminal may not support passing through OSC 4 like tmux does. Only briefly looking through https://github.com/sst/opencode/issues/3688; seems like nvim may need a similar PR to fix it unless I'm missing something.

@garrett-hopper commented on GitHub (Nov 9, 2025): Seems like nvim terminal may not support passing through OSC 4 like tmux does. Only briefly looking through https://github.com/sst/opencode/issues/3688; seems like nvim may need a similar PR to fix it unless I'm missing something.
Author
Owner

@uloco commented on GitHub (Jan 28, 2026):

would be really cool to be able to scroll by just going to normal mode and <c-u> / <c-d> and also visual select then etc.

@uloco commented on GitHub (Jan 28, 2026): would be really cool to be able to scroll by just going to normal mode and `<c-u>` / `<c-d>` and also visual select then etc.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#324