Skip to main content

Developer Hub

REPL

A focused guide for the repl stage of extension development. coc.nvim extensions expose an activate(context) entry point to the Node.js extension host.

Explore APIs with coc-repl

coc-repl starts a Vim or Neovim session with coc.nvim exports available in a Node.js REPL. Use it for experiments and tracing, then move verified code into the extension.

Terminal
1# Start without user extensions or configuration
2npx coc-repl --clean
3 
4# Load and activate the extension in the current directory
5npx coc-repl --noplugin --load .
REPL session
1// Enter these expressions in the connected Node REPL
2await nvim.command('enew!')
3await nvim.buffer.setLines(['coc-repl smoke test'], { start: 0, end: -1 })
4await nvim.buffer.getLines({ start: 0, end: 1 })
5 
6// Load the current workspace extension without restarting the server
7.load .
8ext.isActive

Inspect editor state

Evaluate await nvim.buffer, trace coc.nvim events with --trace, or load an extension with .load.

Common connection failures

Use the same latest coc.nvim checkout for the REPL and editor. If the editor lost the transport, run :CocRestart and reconnect; use --trace or --verbose to inspect the failure. The REPL is a development tool, not an extension runtime dependency.

coc-repl source and commandsRead the complete option, tracing, reconnect, and custom command documentation.