feat: CP submit subcommand #256

Closed
opened 2026-02-27 00:20:11 +00:00 by barrettruth · 1 comment
barrettruth commented 2026-02-27 00:20:11 +00:00

Problem

cp.nvim currently has no way to submit solutions. Users must context-switch to a browser for every submission, which is a significant flow interruption — especially in timed contests. The problem URL is already stored in the cache per problem. Tools like oj (online-judge-tools) and cf-tool provide CLI submission for AtCoder, Codeforces, and others.

Proposed solution

Add :CP submit [--lang <lang>] as a new action. The workflow:

  1. Compile if needed (run the existing build step)
  2. Run all local test cases — abort with a prompt if any fail
  3. Shell out to a configured submission backend with the source file and problem URL
  4. Stream submission output back into a floating window

Configuration would look like:

submit = {
  confirm_on_fail = true,
  backend = "oj",  -- or "cf", or a custom function
}

The problem URL (cache.get_contest_data(platform, contest_id).url) is already tracked. oj submit FILE URL and cf submit -f FILE SPECIFIER are the natural backends.

Verdict tracking (polling for the result after submission) can be a follow-up issue.

Alternatives considered

Delegating entirely to an external tool like cf-tool that the user invokes from the terminal. This works but loses the integration with cp.nvim's current build/test state.

^ NOTE: cf-tool sucks and is archived
NOTE: would have to change the whole "philosphy" section for sure

## Problem cp.nvim currently has no way to submit solutions. Users must context-switch to a browser for every submission, which is a significant flow interruption — especially in timed contests. The problem URL is already stored in the cache per problem. Tools like `oj` (online-judge-tools) and `cf-tool` provide CLI submission for AtCoder, Codeforces, and others. ## Proposed solution Add `:CP submit [--lang <lang>]` as a new action. The workflow: 1. Compile if needed (run the existing build step) 2. Run all local test cases — abort with a prompt if any fail 3. Shell out to a configured submission backend with the source file and problem URL 4. Stream submission output back into a floating window Configuration would look like: ```lua submit = { confirm_on_fail = true, backend = "oj", -- or "cf", or a custom function } ``` The problem URL (`cache.get_contest_data(platform, contest_id).url`) is already tracked. `oj submit FILE URL` and `cf submit -f FILE SPECIFIER` are the natural backends. Verdict tracking (polling for the result after submission) can be a follow-up issue. ## Alternatives considered Delegating entirely to an external tool like `cf-tool` that the user invokes from the terminal. This works but loses the integration with cp.nvim's current build/test state. ^ NOTE: cf-tool sucks and is archived NOTE: would have to change the whole "philosphy" section for sure
barrettruth commented 2026-03-05 20:39:30 +00:00

Submit is shipped and working for CSES, AtCoder, and Codeforces. Remaining platform stubs (CodeChef, Kattis, USACO) tracked in #296.

Submit is shipped and working for CSES, AtCoder, and Codeforces. Remaining platform stubs (CodeChef, Kattis, USACO) tracked in #296.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/cp.nvim#256
No description provided.