## Problem The `CONTEST_ACTIONS` list in `handle_command` was a manually maintained parallel of `ACTIONS` that had already drifted (`pick` was incorrectly included, breaking `:CP pick` cold). `navigate_problem` only cancelled the `'run'` panel on `next`/`prev`, leaving interactive and stress terminals alive and in-flight `run_io_view` callbacks unguarded. `pick` and `cache` also appeared twice in tab-completion when a contest was active. ## Solution Replace `CONTEST_ACTIONS` with a `requires_context` field on `ParsedCommand`, set at each parse-site in `parse_command` so the semantics live with the action definition. Expand `navigate_problem` to call `cancel_io_view()` and dispatch `cancel_interactive`/`stress.cancel` for all panel types, mirroring the contest-switch logic. Filter already-present `pick` and `cache` from the context-conditional completion candidates. |
||
|---|---|---|
| .github | ||
| after/ftplugin | ||
| doc | ||
| lua/cp | ||
| plugin | ||
| scrapers | ||
| scripts | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| .luarc.json | ||
| .pre-commit-config.yaml | ||
| .prettierignore | ||
| .prettierrc | ||
| .python-version | ||
| .styluaignore | ||
| cp.nvim-scm-1.rockspec | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| selene.toml | ||
| stylua.toml | ||
| uv.lock | ||
| vim.yaml | ||
cp.nvim
The definitive competitive programming environment for Neovim
Scrape problems, run tests, and debug solutions across multiple platforms with zero configuration.
https://github.com/user-attachments/assets/e81d8dfb-578f-4a79-9989-210164fc0148
Features
- Multi-platform support: AtCoder, CodeChef, Codeforces, and CSES
- Automatic problem setup: Scrape test cases and metadata in seconds
- Dual view modes: Lightweight I/O view for quick feedback, full panel for detailed analysis
- Test case management: Quickly view, edit, add, & remove test cases
- Rich test output: 256 color ANSI support for compiler errors and program output
- Language agnostic: Works with any language
- Diff viewer: Compare expected vs actual output with 3 diff modes
Installation
Install using your package manager of choice or via luarocks:
luarocks install cp.nvim
Dependencies
Quick Start
cp.nvim follows a simple principle: solve locally, submit remotely.
Basic Usage
-
Find a contest or problem
-
Set up contests locally
:CP codeforces 1848 -
Code and test
:CP run -
Navigate between problems
:CP next :CP prev :CP e1 -
Debug and edit test cases
:CP edit
:CP panel --debug
- Submit on the original website
Documentation
:help cp.nvim
See my config for the setup in the video shown above.
Motivation
I could not find a neovim-centric, efficient, dependency-free, flexible, and easily customizable competitive programming workflow that "just works"--so I made it myself. I conferenced with top competitive programmers at Carnegie Mellon Univerity and the University of Virginia and covered their (and my) pain points:
- Scraping: contests are automatically loaded asynchronously
- Test Case Management: test case editor (
:CP edit) - UI: both
runandpanellayouts cover common formats - Extensibility: snippet plugins, compilation, etc. are left to the programmer