Skip to content

Conversation

@KKrampis
Copy link
Contributor

@KKrampis KKrampis commented Aug 15, 2025

Added the option to have it as buffer / split panel within neovim (can be enabled with true-false in the plugin configuration file). Also allows for vim normal mode yanking of output from codex and pasting into any other open buffer.

2025-08-14T22:26:54,443827083-04:00

@alduro
Copy link

alduro commented Oct 14, 2025

this is what I need :-)

@johnseth97
Copy link
Owner

johnseth97 commented Nov 13, 2025

@KKrampis I'd like to merge this, can you resolve the new conflicts first?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds two new configuration options to the Codex Neovim plugin: the ability to display Codex in a side panel (vertical split) instead of a floating window, and the ability to capture Codex output in a normal buffer instead of a terminal buffer (enabling vim yank/paste operations).

Key changes:

  • Added panel configuration option to toggle between floating window and side panel display modes
  • Added use_buffer configuration option to capture stdout/stderr in a normal buffer for copy/paste functionality
  • Updated repository references from johnseth97 to kkrampis

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
lua/codex/init.lua Implements new open_panel() function and use_buffer mode with jobstart callbacks for capturing output; adds configuration options
README.md Documents the new panel and use_buffer configuration options; updates repository owner references

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +179 to +200
on_stdout = function(_, data)
if not data then return end
for _, line in ipairs(data) do
if line ~= '' then
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, { line })
end
end
end,
on_stderr = function(_, data)
if not data then return end
for _, line in ipairs(data) do
if line ~= '' then
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, { '[ERR] ' .. line })
end
end
end,
on_exit = function(_, code)
state.job = nil
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, {
('[Codex exit: %d]'):format(code),
})
end,
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The on_stdout, on_stderr, and on_exit callbacks don't verify that state.buf is still valid before writing to it. If the user closes the buffer while the job is still running, nvim_buf_set_lines will throw an error. Add a buffer validity check:

if not vim.api.nvim_buf_is_valid(state.buf) then return end

at the start of each callback.

Copilot uses AI. Check for mistakes.
Comment on lines +175 to +203
-- capture stdout/stderr into normal buffer
state.job = vim.fn.jobstart(cmd_args, {
cwd = vim.loop.cwd(),
stdout_buffered = true,
on_stdout = function(_, data)
if not data then return end
for _, line in ipairs(data) do
if line ~= '' then
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, { line })
end
end
end,
on_stderr = function(_, data)
if not data then return end
for _, line in ipairs(data) do
if line ~= '' then
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, { '[ERR] ' .. line })
end
end
end,
on_exit = function(_, code)
state.job = nil
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, {
('[Codex exit: %d]'):format(code),
})
end,
})
else
-- use a terminal buffer
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Inconsistent inline comment style. Line 175 uses -- capture stdout/stderr into normal buffer (lowercase, no period) while line 203 uses -- use a terminal buffer (lowercase, no period). For consistency with the function-level comment on line 88 which uses proper capitalization and punctuation, consider standardizing all comments to use sentence case with proper punctuation.

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +93
local win = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(win, state.buf)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The open_panel() function uses vim.cmd('vertical rightbelow vsplit') which creates a new empty buffer before switching to state.buf. This temporarily creates an unnecessary buffer. Consider using vim.api.nvim_open_win(state.buf, true, {...}) with appropriate split configuration, or explicitly delete the temporary buffer after the split.

Suggested change
local win = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(win, state.buf)
local win = vim.api.nvim_get_current_win()
local tmp_buf = vim.api.nvim_win_get_buf(win)
vim.api.nvim_win_set_buf(win, state.buf)
-- Delete the temporary buffer if it's not the same as state.buf and is listed
if tmp_buf ~= state.buf and vim.api.nvim_buf_is_valid(tmp_buf) then
-- Only delete if the buffer is listed (to avoid deleting user buffers)
if vim.api.nvim_buf_get_option(tmp_buf, 'buflisted') then
vim.api.nvim_buf_delete(tmp_buf, { force = true })
end
end

Copilot uses AI. Check for mistakes.
panel = false, -- Open Codex in a side-panel (vertical split) instead of floating window
use_buffer = false, -- Capture Codex stdout into a normal buffer instead of a terminal buffer
},
}```
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code block syntax is malformed. Line 54 shows `}````, which combines the closing brace with the three backticks. These should be on separate lines for proper markdown formatting:

  },
}

(closing backticks on next line)

Suggested change
}```
}

Copilot uses AI. Check for mistakes.
if config.panel then open_panel() else open_window() end

if not state.job then
-- assemble command
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inline comment -- assemble command should be capitalized and end with a period for consistency with documentation standards: -- Assemble command.

Suggested change
-- assemble command
-- Assemble command.

Copilot uses AI. Check for mistakes.
Comment on lines +174 to +201
if config.use_buffer then
-- capture stdout/stderr into normal buffer
state.job = vim.fn.jobstart(cmd_args, {
cwd = vim.loop.cwd(),
stdout_buffered = true,
on_stdout = function(_, data)
if not data then return end
for _, line in ipairs(data) do
if line ~= '' then
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, { line })
end
end
end,
on_stderr = function(_, data)
if not data then return end
for _, line in ipairs(data) do
if line ~= '' then
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, { '[ERR] ' .. line })
end
end
end,
on_exit = function(_, code)
state.job = nil
vim.api.nvim_buf_set_lines(state.buf, -1, -1, false, {
('[Codex exit: %d]'):format(code),
})
end,
})
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using use_buffer = true, the buffer is not a terminal buffer, so users cannot interact with the Codex CLI (send input). The jobstart call doesn't configure stdin handling. If the Codex CLI requires user input, consider either:

  1. Adding stdin = 'pipe' and implementing an input mechanism
  2. Documenting that use_buffer = true is read-only and doesn't support interactive sessions
  3. Using pty = true to enable terminal-like behavior while still capturing output

Currently, this creates a non-interactive experience that may not work correctly with Codex CLI.

Copilot uses AI. Check for mistakes.
cmd = 'codex',
model = nil, -- Default to the latest model
autoinstall = true,
panel = false, -- if true, open Codex in a side-panel instead of floating window
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inline comments for the new config options use inconsistent spacing. Line 15 has panel = false, with extra spaces, while line 16 has use_buffer = false, with normal spacing. Align the equals signs consistently for better readability.

Suggested change
panel = false, -- if true, open Codex in a side-panel instead of floating window
panel = false, -- if true, open Codex in a side-panel instead of floating window

Copilot uses AI. Check for mistakes.
@johnseth97 johnseth97 merged commit e1149cb into johnseth97:main Nov 20, 2025
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.

3 participants