Commit graph

7 commits

Author SHA1 Message Date
Barrett Ruth
2776aaeb21
fix: correct Codeforces language version IDs and default to C++20 (#349)
## Problem

`LANGUAGE_VERSIONS` mapped CF `c++17` to `89` (actually GNU G++20) and
defaulted to `c++17`, which didn't match any CF entry. Helpdocs listed
CF as having only `c++17`.

## Solution

Fix CF version map to `c++17 → 54`, `c++20 → 89`, `c++23 → 91`, add
`pypy3 → 70`. Change `DEFAULT_VERSIONS.cpp` to `c++20` (no behavioral
change — `89` was already the submit default). Update helpdocs. Fix
StyLua formatting in `race.lua`.
2026-03-06 19:01:55 -05:00
Barrett Ruth
8398f3428e
feat(race): notification tiers, drift correction, and T=0 retry (#348)
## Problem

Race countdown had three reliability issues:
- Notified every second regardless of remaining time (noisy for
hours-long waits)
- Never re-fetched start times (stale if contest rescheduled)
- No retry on setup failure at T=0 — if the scraper failed at the most
critical moment, the entire countdown was wasted

## Solution

- **Notification tiers**: >1h every 15m, >5m every 1m, >1m every 10s,
≤60s every 1s
- **Drift correction**: re-fetch contest list every 10 minutes, update
`start_time` if changed
- **T=0 retry**: `race_try_setup` calls `scrape_contest_metadata` with
the new `on_error` callback, retrying up to 15 times at 3s intervals
(~45s). Caches metadata on success, then calls `setup_contest` on the
fast (cached) path. Token guard invalidates stale retries after
cancellation.
- **`on_error` for `scrape_contest_metadata`**: optional 4th param,
backward-compatible
2026-03-06 18:43:12 -05:00
Barrett Ruth
bd0ae25d4b
refactor(race): replace :CP race with --race flag (#347)
## Problem

Race was the only command using `:CP <action> <platform> <contest>`
syntax while every other platform+contest command uses `:CP <platform>
<contest> [flags]`.

## Solution

Make race a `--race` flag on the existing contest setup flow. Remove
`:CP race stop` — starting a new race auto-cancels any active one.
Remove `<Plug>(cp-race-stop)` keymap. Update tab completion and docs
accordingly.
2026-03-06 18:33:42 -05:00
Barrett Ruth
58b6840815
feat: race countdown support and language version selection (#346)
## Problem

Two gaps in the plugin: (1) contest pickers have no way to know whether
a contest supports countdown (race), so the UI can't surface that
affordance; (2) `:CP submit` hardcodes a single language ID per platform
with no way to choose C++ standard or override the platform ID.

## Solution

**Race countdown** (`4e709c8`): Add `supports_countdown` boolean to
`ContestListResult` and wire it through CSES/USACO scrapers, cache, race
module, and pickers.

**Language version selection** (`b90ac67`): Add `LANGUAGE_VERSIONS` and
`DEFAULT_VERSIONS` tables in `constants.lua`. Config gains `version` and
`submit_id` fields validated at setup time. `submit.lua` resolves the
effective config to a platform ID (priority: `submit_id` > `version` >
default). Helpdocs add `*cp-submit-language*` section. Tests cover
`LANGUAGE_IDS` completeness.
2026-03-06 18:18:21 -05:00
Barrett Ruth
a202725cc5
fix(submit): use file path over stdin; fix CF CodeMirror textarea (#305)
## Problem

After the initial submit hardening, two issues remained: source code was
read in Lua and piped as stdin to the scraper (unnecessary roundtrip
since
the file exists on disk), and CF's `page.fill()` timed out on the hidden
`textarea[name="source"]` because CodeMirror owns the editor state.

## Solution

Pass the source file path as a CLI arg instead — AtCoder calls
`page.set_input_files(file_path)` directly, CF reads it with
`Path(file_path).read_text()`. Fix CF source injection via
`page.evaluate()`
into the CodeMirror instance. Extract `BROWSER_SUBMIT_NAV_TIMEOUT` as a
per-platform `defaultdict` (CF defaults to 2× nav timeout). Save the
buffer
with `vim.cmd.update()` before submitting.
2026-03-05 14:34:14 -05:00
e79f992e0b fix: resolve lua typecheck warnings in race and scraper
Problem: luals flagged undefined-field on uv timer methods because
race_state.timer was untyped, and undefined-field on env_extra/stdin
because they were missing from the run_scraper opts annotation.

Solution: hoist race_state.timer into a typed local before the nil
check so luals can narrow through it; add env_extra and stdin to the
opts inline type in run_scraper.
2026-03-03 15:09:41 -05:00
f5c1b978a2 feat(race): add contest countdown timer
Add race.lua with a 1-second vim.uv timer that counts down to a contest
start time and auto-calls setup.setup_contest() at T=0. Exposes
M.start(), M.stop(), and M.status() for command dispatch and statusline
integration.
2026-03-03 15:09:41 -05:00