From 58b68408156400f3cd6589ec7088203a0e771f4b Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Fri, 6 Mar 2026 18:18:21 -0500 Subject: [PATCH] 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. --- doc/cp.nvim.txt | 72 +++++++++++++++++++++++++++++++++++------ lua/cp/cache.lua | 26 ++++++++++++++- lua/cp/config.lua | 27 ++++++++++++++++ lua/cp/constants.lua | 17 ++++++++++ lua/cp/pickers/init.lua | 6 ++-- lua/cp/race.lua | 65 ++++++++++++++++++++++++------------- lua/cp/scraper.lua | 7 ++-- lua/cp/submit.lua | 22 ++++++++++++- plugin/cp.lua | 22 +++++++++++-- scrapers/cses.py | 8 +++-- scrapers/models.py | 1 + scrapers/usaco.py | 12 +++++-- tests/test_scrapers.py | 26 +++++++++++++++ 13 files changed, 265 insertions(+), 46 deletions(-) diff --git a/doc/cp.nvim.txt b/doc/cp.nvim.txt index 1db397b..add0bcb 100644 --- a/doc/cp.nvim.txt +++ b/doc/cp.nvim.txt @@ -24,15 +24,16 @@ CONTENTS *cp-contents* 16. Race .......................................................... |cp-race| 17. Credentials ............................................ |cp-credentials| 18. Submit ...................................................... |cp-submit| - 19. Open ......................................................... |cp-open| - 20. ANSI Colors ................................................... |cp-ansi| - 21. Highlight Groups ........................................ |cp-highlights| - 22. Terminal Colors .................................... |cp-terminal-colors| - 23. Highlight Customization .......................... |cp-highlight-custom| - 24. Helpers .................................................... |cp-helpers| - 25. Statusline Integration .................................. |cp-statusline| - 26. Panel Keymaps .......................................... |cp-panel-keys| - 27. File Structure ................................................ |cp-files| + 19. Submit Language Versions ......................... |cp-submit-language| + 20. Open ......................................................... |cp-open| + 21. ANSI Colors ................................................... |cp-ansi| + 22. Highlight Groups ........................................ |cp-highlights| + 23. Terminal Colors .................................... |cp-terminal-colors| + 24. Highlight Customization .......................... |cp-highlight-custom| + 25. Helpers .................................................... |cp-helpers| + 26. Statusline Integration .................................. |cp-statusline| + 27. Panel Keymaps .......................................... |cp-panel-keys| + 28. File Structure ................................................ |cp-files| 28. Health Check ................................................ |cp-health| ============================================================================== @@ -1032,7 +1033,58 @@ Submit the current solution to the online judge. Platform support: AtCoder Fully implemented. - Others Not yet implemented. + Codeforces Fully implemented. + CSES Fully implemented. + Kattis Fully implemented. + USACO Fully implemented. + CodeChef Not yet implemented. + + See |cp-submit-language| for configuring the language version + (e.g. C++20 instead of C++17). + +============================================================================== +SUBMIT LANGUAGE VERSIONS *cp-submit-language* + +When submitting, cp.nvim selects a language version for the platform. +The default is C++17 for cpp and Python 3 for python. + +Configuring a version ~ + +Set {version} globally or per-platform: +>lua + languages = { + cpp = { version = "c++20", ... }, + }, + platforms = { + atcoder = { + overrides = { cpp = { version = "c++23" } }, + }, + }, +< +Available versions per platform ~ + + Platform cpp python + AtCoder c++23 python3 + Codeforces c++17 python3 + CSES c++17 python3 + Kattis c++17/20/23 python3 + USACO c++17/20/23 python3 + CodeChef c++17 python3 + +Using a raw platform ID ~ + +If your preferred version is not listed, you can bypass version +lookup by setting {submit_id} to the raw platform language ID: +>lua + platforms = { + codeforces = { + overrides = { cpp = { submit_id = "91" } }, + }, + }, +< +To find the raw ID, open the platform's submit page in your browser, +inspect the language dropdown, and copy the