feat: contest start countdown and auto-setup (CP race) #264

Closed
opened 2026-02-27 00:21:40 +00:00 by barrettruth · 0 comments
barrettruth commented 2026-02-27 00:21:40 +00:00

Problem

In rated contests, the moment a contest opens the fastest setup wins. Currently users must manually run :CP codeforces 2050 the instant the contest begins. cf-tool has cf race CONTEST_ID which counts down to contest start time and automatically parses all problems the instant they become available.

Proposed solution

Add :CP race <platform> <contest_id> which:

  1. Queries the platform API for the contest start time (Codeforces has a public /api/contest.list endpoint returning startTimeSeconds)
  2. Computes time remaining and displays a countdown via vim.notify updates using vim.uv.new_timer
  3. At T=0, automatically calls the existing setup_contest flow
  4. Can be cancelled with :CP race stop

The countdown could also be surfaced via cp.statusline.component() (issue #263).

This requires only a vim.uv.new_timer + one HTTP/API call, reusing all existing setup infrastructure.

Alternatives considered

Manual invocation at contest start. This works but the race mode is a meaningful convenience for regular contest participants — especially since Codeforces contests start at a precise second.

## Problem In rated contests, the moment a contest opens the fastest setup wins. Currently users must manually run `:CP codeforces 2050` the instant the contest begins. `cf-tool` has `cf race CONTEST_ID` which counts down to contest start time and automatically parses all problems the instant they become available. ## Proposed solution Add `:CP race <platform> <contest_id>` which: 1. Queries the platform API for the contest start time (Codeforces has a public `/api/contest.list` endpoint returning `startTimeSeconds`) 2. Computes time remaining and displays a countdown via `vim.notify` updates using `vim.uv.new_timer` 3. At T=0, automatically calls the existing `setup_contest` flow 4. Can be cancelled with `:CP race stop` The countdown could also be surfaced via `cp.statusline.component()` (issue #263). This requires only a `vim.uv.new_timer` + one HTTP/API call, reusing all existing setup infrastructure. ## Alternatives considered Manual invocation at contest start. This works but the race mode is a meaningful convenience for regular contest participants — especially since Codeforces contests start at a precise second.
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#264
No description provided.