Commit graph

111 commits

Author SHA1 Message Date
4f307e323d
fix(config): avoid doubling slug in default_filename for single-problem mode
Problem: Kattis single-problem mode sets both `contest_id` and
`problem_id` to the same slug, causing `default_filename` to
concatenate them (e.g. `addtwonumbersaddtwonumbers.cc`).

Solution: only concatenate when `problem_id ~= contest_id`; otherwise
return just `problem_id` (or `contest_id` if nil).
2026-03-07 02:32:52 -05:00
Barrett Ruth
3c11d609f5
feat(codechef): implement full CodeChef support (#354)
## Problem

CodeChef had no working login, submit, or contest list. The browser
selectors were wrong, the contest list was missing present/past
contests,
and problem/contest URLs were unset.

## Solution

Fix login and submit selectors for the Drupal-based site. Paginate
`/api/list/contests/past` to collect all 228 Starters, then expand each
parent contest into individual division entries (e.g. `START228 (Div.
4)`).
Add language IDs, correct `url`/`contest_url`/`standings_url` in
metadata,
and make `:CP <platform>` open the contest picker directly.
2026-03-06 23:10:44 -05:00
Barrett Ruth
291de4e137
fix: expand language IDs, fix AtCoder submit, normalize logging (#353)
## Problem

Language version coverage was incomplete across all platforms, AtCoder
submit used a stale cookie fast-path that caused silent failures, and
raw
`vim.notify` calls throughout the codebase produced inconsistent or
missing `[cp.nvim]:` prefixes.

## Solution

Remove cookie persistence from AtCoder login/submit (always fresh
login),
increase the submit nav timeout to 40s, and switch to in-memory buffer
upload with the correct per-language extension from a full
`_LANGUAGE_ID_EXTENSION`
map covering all 116 AtCoder languages. Expand `LANGUAGE_VERSIONS` in
`constants.lua` with all AtCoder languages, 15 new CF languages with
full
version variants, and 50+ Kattis languages. Fix AtCoder `prolog` ID
(`6079`→`6081`, was Pony) and remove the non-existent `racket` entry.
Replace all raw `vim.notify` calls with `logger.log`. Simplify the
submit
language doc to point at `constants.lua` rather than maintaining a
static table.
2026-03-06 21:35:13 -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
e89c57558d
feat(config): merge platform config model and add disabled-platform guard (#336)
## Problem

Supplying any `platforms` table silently dropped all unlisted platforms,
making it easy to accidentally disable platforms. Invoking a disabled
platform produced no user-facing error.

## Solution

Switch to a merge model: all six platforms are enabled by default and
user entries are deep-merged on top. Set a platform key to `false` to
disable it explicitly. Add a `check_platform_enabled` guard in
`handle_command` for contest fetch, login, logout, and race actions.
2026-03-06 16:14:16 -05:00
Barrett Ruth
2d50f0a52a
refactor: remove open_url config option in favour of :CP open (#322)
## Problem

`open_url` automatically opened the browser on contest load and problem
change, which is now redundant with `:CP open`.

## Solution

Remove the `open_url` field from `cp.Config`, its default, its
validation, and the call site in `setup_contest`. Remove documentation
from `cp.nvim.txt`.
2026-03-05 22:55:43 -05:00
4f88b19a82 refactor(run): remove I/O view test navigation keymaps
Problem: <c-n>/<c-p> in the I/O view buffers required the cursor
to leave the source file to work, re-ran the solution on each
press, and gave no indication of which test was active. The
workflow is better served by :CP run <n> for a specific test or
:CP panel for full inspection.

Solution: remove navigate_test, next_test_key/prev_test_key config
options, and the associated current_test_index state field.
2026-03-04 00:26:22 -05:00
4e8da84882 feat(platforms): add kattis and usaco scrapers
Add KattisScraper and USACOScraper with contest list, metadata, and
test case fetching. Register kattis and usaco in PLATFORMS,
PLATFORM_DISPLAY_NAMES, and default platform configs.
2026-03-03 15:09:41 -05:00
72ea6249f4 ci: format 2026-03-03 00:46:59 -05:00
add022af8c refactor(hooks): replace flat hooks API with setup/on namespaces
Problem: the hooks API conflated distinct lifecycle scopes under a flat
table with inconsistent naming (setup_code, before_run, setup_io_input),
making it hard to reason about when each hook fires.

Solution: introduce two namespaces — hooks.setup.{contest,code,io} for
one-time initialization and hooks.on.{enter,run,debug} for recurring
events. hooks.setup.contest fires once when a contest dir is newly
created; hooks.on.enter is registered as a buffer-scoped BufEnter
autocmd and fires immediately after setup.code. The provisional buffer
setup_code callsite is removed as it ran on an unresolved temp buffer.
2026-03-03 00:46:59 -05:00
6a395af98f feat(config): add templates.cursor_marker for post-template cursor placement
Problem: after apply_template writes a file's content to the buffer,
cursor positioning was left entirely to the user's setup_code hook,
forcing everyone to reimplement the same placeholder-stripping logic.

Solution: add an optional templates.cursor_marker config key. When set,
apply_template scans the written lines for the marker, strips it, and
positions the cursor there via bufwinid so it works in both the
provisional and existing-file paths.
2026-03-03 00:46:59 -05:00
d3324aafa3 fix(config): propagate template through platform overrides
Problem: CpPlatformOverrides lacked a template field and merge_lang()
never copied ov.template into the effective language config, so
per-platform template overrides were silently dropped.

Solution: add template? to CpPlatformOverrides and forward it in
merge_lang(), matching how extension is handled.
2026-03-03 00:46:59 -05:00
e685a8089f feat: add epsilon tolerance for floating-point output comparison
Problem: output comparison used exact string equality after whitespace
normalisation, causing correct solutions to fail on problems where
floating-point answers are accepted within a tolerance (e.g. 1e-6).

Solution: add an optional ui.panel.epsilon config value. When set,
actual and expected output are compared token-by-token: numeric tokens
are compared with math.abs(a - b) <= epsilon, non-numeric tokens fall
back to exact string equality. Per-problem epsilon can also be stored
in the cache and takes precedence over the global default.
2026-02-26 23:00:35 -05:00
2c25ec616a feat: add per-language template file support
Problem: new solution files were always created empty, requiring users
to manually paste boilerplate or rely on editor snippets that fire
outside cp.nvim's control.

Solution: add an optional template field to the language config. When
set to a file path, its contents are written into every newly created
solution buffer before the setup_code hook runs. Existing files are
never overwritten.
2026-02-26 22:57:39 -05:00
06f72bbe2b fix: only show user-configured platforms in picker
Problem: tbl_deep_extend merges user platforms on top of defaults, so
all four default platforms survive even when the user only configures a
subset. The picker then shows platforms the user never intended to use.

Solution: before the deep merge, prune any default platform not present
in the user's platforms table. This preserves per-platform default
filling (the user doesn't have to re-specify every field) while ensuring
only explicitly configured platforms appear.
2026-02-18 17:29:41 -05:00
d496509fce feat(config): improve config parsing phrasing 2026-01-27 17:33:16 -05:00
383b327442 fix(config): validate scraper names better 2026-01-27 17:32:21 -05:00
3f677137de fix(config): one of validation 2026-01-27 17:27:15 -05:00
0a1cea9b43 feat: debug 2026-01-27 17:25:03 -05:00
d89a40b21f feat: update git formatting 2026-01-27 17:18:52 -05:00
Barrett Ruth
e89c2e1cf5 feat(codechef): finalize codechef impl 2025-10-25 01:41:55 -04:00
Barrett Ruth
181fff42de feat(ui): documentation for :CP edit abilities 2025-10-24 16:35:00 -04:00
Barrett Ruth
4b1b75fd6e fix(config): padding spacing 2025-10-24 14:44:33 -04:00
Barrett Ruth
f52244c534 better errors 2025-10-24 01:32:48 -04:00
Barrett Ruth
bd30fb626c feat: start lang refactor 2025-10-24 01:11:19 -04:00
Barrett Ruth
f715075dbe fix types 2025-10-24 00:34:42 -04:00
Barrett Ruth
249e84eb5a feat: customization 2025-10-24 00:26:14 -04:00
Barrett Ruth
9ffc285e16 feat: document bdingins 2025-10-23 23:45:05 -04:00
Barrett Ruth
6a6cf2c594 feat: bindings and --debug flag 2025-10-23 23:36:09 -04:00
Barrett Ruth
c312ccbb4d fix: highlighting 2025-10-23 18:16:36 -04:00
Barrett Ruth
13933fc7fd feat: clearcol 2025-10-23 12:10:14 -04:00
Barrett Ruth
114187164e improve some refactors 2025-10-23 11:16:13 -04:00
Barrett Ruth
018d801121 fix: rename run panel to panel 2025-10-23 09:54:55 -04:00
c0e175d84b feat(config): open url option 2025-10-12 16:19:02 -04:00
b68ecbbe96 rename and simplify things 2025-10-05 11:59:24 -04:00
d2bde9bad8 fix(config): better file org 2025-10-04 19:54:53 -04:00
a76d228e3f feat(doc): update for new config 2025-10-04 19:04:49 -04:00
aae98a5796 disable scraper disabling 2025-10-04 17:45:49 -04:00
0a320945a0 fix(config): platforms, not contests 2025-10-04 16:29:35 -04:00
3fbbfa9423 normalize scraper behavior 2025-10-04 16:13:04 -04:00
91dbc4560c fix(ci): unused var 2025-10-02 23:49:45 -04:00
cddd61f061 config hard fail 2025-10-02 23:20:51 -04:00
1974addbd2 fix(lua): bunch of typing 2025-10-02 14:18:26 -04:00
57be0c0044 remove keys 2025-10-02 10:23:01 -04:00
b406c0ce4e fix: synchronous problem fetch 2025-10-01 12:25:07 -04:00
46cd509747 fix docs and superfluous vim.validate calls 2025-09-30 20:55:29 -04:00
f0fbb15765 fix: default contest config 2025-09-26 09:28:23 -04:00
b41ed5be13 feat: provide default contest config 2025-09-26 09:15:43 -04:00
7efd6404b6 feat: interactive terminal 2025-09-26 08:28:19 -04:00
975e829f78 fix: remove version 2025-09-24 18:28:41 -04:00