
A Neovim IDE integration for Codex. It follows the original architecture of the Claude Code integration and adapts it for Codex. will continue to be improved.
{
dir = "/home/dev_local/dev_plugin/codex.nvim",
dependencies = { "folke/snacks.nvim" },
config = true,
keys = {
{ "<leader>cc", "<cmd>Codex<cr>", desc = "Codex: Toggle" },
{ "<leader>cf", "<cmd>CodexFocus<cr>", desc = "Codex: Focus" },
{ "<leader>cs", "<cmd>CodexSend<cr>", mode = "v", desc = "Codex: Send selection" },
{
"<leader>cs",
"<cmd>CodexTreeAdd<cr>",
desc = "Codex: Add file",
ft = { "neo-tree", "oil" },
},
},
}
folke/snacks.nvim recommended for terminal UX:Codex:CodexSend:CodexTreeAdd
Only neo-tree and oil.nvim are supported tree views.require("codex").setup({
terminal_cmd = "/path/to/codex",
})
require("codex").setup({
env = {
ENABLE_IDE_INTEGRATION = "true",
CODEX_CODE_SSE_PORT = "12345",
},
})
Accurate busy/wait display requires Codex CLI notify events. Without notify configuration, codex.nvim cannot reliably detect active responses, so the busy/wait indicator is not guaranteed. Set the notify file path and environment variable in codex.nvim, and configure Codex CLI to append JSON events to that file.
require("codex").setup({
env = {
CODEX_NVIM_NOTIFY_PATH = "/tmp/codex.nvim/notify.jsonl",
},
status_indicator = {
cli_notify_path = "/tmp/codex.nvim/notify.jsonl",
-- Maximum time to keep the busy indicator during a response (milliseconds)
turn_active_timeout_ms = 300000,
-- Grace period before clearing busy after output stops (milliseconds)
turn_idle_grace_ms = 2000,
-- Grace period to ignore stale inflight requests (milliseconds)
inflight_timeout_ms = 300000,
},
})
Codex CLI config example:
notify = ["sh", "/path/to/codex.nvim/scripts/codex_notify.sh"]
Only agent-turn-complete is handled for now, so response start is inferred from input.
When using an external terminal, Neovim cannot observe Codex CLI output, so the busy indicator relies solely on notify events. If notify is not configured, busy is inferred only from input/output grace periods.
When a diff is pending (user choice), the indicator shows ◐.
This plugin is heavily inspired by the design and implementation of claudecode.nvim. The repository referenced is https://github.com/coder/claudecode.nvim. Many thanks to its maintainers.
Codex を Neovim から扱うための IDE 統合プラグインです。Claude Code 用に作られた設計を踏襲しつつ、Codex 用に調整しています。 今後も改善を続ける予定です。
{
dir = "/home/dev_local/dev_plugin/codex.nvim",
dependencies = { "folke/snacks.nvim" },
config = true,
keys = {
{ "<leader>cc", "<cmd>Codex<cr>", desc = "Codex: Toggle" },
{ "<leader>cf", "<cmd>CodexFocus<cr>", desc = "Codex: Focus" },
{ "<leader>cs", "<cmd>CodexSend<cr>", mode = "v", desc = "Codex: 選択範囲を送信" },
{
"<leader>cs",
"<cmd>CodexTreeAdd<cr>",
desc = "Codex: ファイルを追加",
ft = { "neo-tree", "oil" },
},
},
}
neo-tree のポップアップ(filetype: neo-tree-popup)にも同じキーマップが適用されます。oil.nvim(filetype: oil)でも同様に使えます。
folke/snacks.nvim を推奨:Codex で Codex ターミナルを開きます:CodexSend で送信します:CodexTreeAdd が使えます
neo-tree と oil.nvim のみ対応しています。既定は Ctrl-] で前のウィンドウへ戻ります。macOS で Cmd-] にしたい場合は terminal.unfocus_key を設定してください。
require("codex").setup({
terminal = {
unfocus_key = "<D-]>", -- Cmd-] でフォーカスを戻す
},
})
Issue や PR 歓迎です。バグ報告や改善提案を気軽にお寄せください。
Codex CLI が通常のパスに無い場合は terminal_cmd を指定してください。
require("codex").setup({
terminal_cmd = "/path/to/codex",
})
Codex CLI 起動時に渡す環境変数を追加できます。
require("codex").setup({
env = {
ENABLE_IDE_INTEGRATION = "true",
CODEX_CODE_SSE_PORT = "12345",
},
})
動作中や選択待ちを正しく表示するには、Codex CLI の notify を使って完了イベントを通知する必要があります。プラグインに通知ファイルのパスと環境変数を設定し、Codex CLI 側でそのファイルへ追記する設定を行ってください。
require("codex").setup({
env = {
CODEX_NVIM_NOTIFY_PATH = "/tmp/codex.nvim/notify.jsonl",
},
status_indicator = {
cli_notify_path = "/tmp/codex.nvim/notify.jsonl",
},
})
Codex CLI の設定例:
notify = ["sh", "/path/to/codex.nvim/scripts/codex_notify.sh"]
通知イベントは現時点で agent-turn-complete のみ対応のため、応答開始は入力検知で補完します。
差分の選択待ち(承認/拒否の保留)がある場合は ◐ を表示します。
本プラグインは claudecode.nvim の設計と実装に大きく助けられました。参考にしたリポジトリは https://github.com/coder/claudecode.nvim です。開発者の皆さまに感謝します。