Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 1.72 KB

File metadata and controls

66 lines (45 loc) · 1.72 KB

Development

Setup

Use an editable symlink so Vim loads your working tree directly:

mkdir -p ~/.vim/pack/dev/start
ln -s /path/to/codex-vim9 ~/.vim/pack/dev/start/codex-vim9

Inside Vim or MacVim, reload the plugin with:

:CodexReload

Layout

  • plugin/codex_vim.vim: the plugin implementation
  • doc/codex_vim.txt: Vim help
  • test/*.vim: headless Vim tests
  • test/capture_codex.py, test/tool_server.py: fake Codex servers for deterministic tests

Architecture

The plugin is a single Vim9 script that:

  • starts codex app-server over stdio
  • initializes with capabilities.experimentalApi = true
  • persists one thread id per scope under the state dir
  • builds JSON editor context from the current buffer, selection, and surrounding lines
  • handles both ordinary turn responses and dynamic tool calls

vim_normal is always registered on new threads. Per-turn gating is enforced locally:

  • :CodexShow disables tool use for that turn
  • :CodexShowTool enables tool use for that turn
  • if Codex calls the tool while disabled, the plugin returns a tool error

Tests

Run the offline suite:

./test.sh

Current offline coverage:

  • smoke_basic: command load/reload and basic startup
  • cursor_context: prompt context JSON shape
  • tool_gate: tool registration, enabled path, rejected path, and undo behavior

Run the live roundtrip only when the change plausibly affects the real Codex path:

./test.sh live_apply

Working Notes

  • Keep tests focused and deterministic. Prefer fake app-server helpers over brittle UI tests.
  • Use apply_patch for edits.
  • Update README.md and doc/codex_vim.txt when behavior changes.
  • Run chkstyle after editing Python test helpers.