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.
This commit is contained in:
Barrett Ruth 2026-03-06 18:18:21 -05:00 committed by GitHub
parent 592f977296
commit 58b6840815
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 265 additions and 46 deletions

View file

@ -8,6 +8,8 @@
---@field extension string
---@field commands CpLangCommands
---@field template? string
---@field version? string
---@field submit_id? string
---@class CpTemplatesConfig
---@field cursor_marker? string
@ -16,6 +18,8 @@
---@field extension? string
---@field commands? CpLangCommands
---@field template? string
---@field version? string
---@field submit_id? string
---@class CpPlatform
---@field enabled_languages string[]
@ -293,6 +297,12 @@ local function merge_lang(base, ov)
if ov.template then
out.template = ov.template
end
if ov.version then
out.version = ov.version
end
if ov.submit_id then
out.submit_id = ov.submit_id
end
return out
end
@ -323,6 +333,23 @@ local function build_runtime(cfg)
validate_language(lid, base)
local eff = merge_lang(base, p.overrides and p.overrides[lid] or nil)
validate_language(lid, eff)
if eff.version then
local normalized = eff.version:lower():gsub('%s+', '')
local versions = (constants.LANGUAGE_VERSIONS[plat] or {})[lid]
if not versions or not versions[normalized] then
local avail = versions and vim.tbl_keys(versions) or {}
table.sort(avail)
error(
("[cp.nvim] Unknown version '%s' for %s on %s. Available: [%s]. See :help cp-submit-language"):format(
eff.version,
lid,
plat,
table.concat(avail, ', ')
)
)
end
eff.version = normalized
end
cfg.runtime.effective[plat][lid] = eff
end
end