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:
parent
592f977296
commit
58b6840815
13 changed files with 265 additions and 46 deletions
|
|
@ -1,6 +1,8 @@
|
|||
local M = {}
|
||||
|
||||
local cache = require('cp.cache')
|
||||
local config = require('cp.config')
|
||||
local constants = require('cp.constants')
|
||||
local logger = require('cp.log')
|
||||
local state = require('cp.state')
|
||||
|
||||
|
|
@ -56,6 +58,24 @@ function M.submit(opts)
|
|||
end
|
||||
source_file = vim.fn.fnamemodify(source_file, ':p')
|
||||
|
||||
local submit_language = language
|
||||
local cfg = config.get_config()
|
||||
local plat_effective = cfg.runtime and cfg.runtime.effective and cfg.runtime.effective[platform]
|
||||
local eff = plat_effective and plat_effective[language]
|
||||
if eff then
|
||||
if eff.submit_id then
|
||||
submit_language = eff.submit_id
|
||||
else
|
||||
local ver = eff.version or constants.DEFAULT_VERSIONS[language]
|
||||
if ver then
|
||||
local versions = (constants.LANGUAGE_VERSIONS[platform] or {})[language]
|
||||
if versions and versions[ver] then
|
||||
submit_language = versions[ver]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
prompt_credentials(platform, function(creds)
|
||||
vim.cmd.update()
|
||||
vim.notify('[cp.nvim] Submitting...', vim.log.levels.INFO)
|
||||
|
|
@ -64,7 +84,7 @@ function M.submit(opts)
|
|||
platform,
|
||||
contest_id,
|
||||
problem_id,
|
||||
language,
|
||||
submit_language,
|
||||
source_file,
|
||||
creds,
|
||||
function(ev)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue