Commit graph

45 commits

Author SHA1 Message Date
Barrett Ruth
b53c8ca44e
fix(security): harden credential storage and transmission (#369)
Some checks are pending
luarocks / ci (push) Waiting to run
luarocks / publish (push) Blocked by required conditions
## Problem

Credential and cookie files were world-readable (0644), passwords
transited via `CP_CREDENTIALS` env var (visible in `/proc/PID/environ`),
and Kattis/USACO echoed passwords back through stdout unnecessarily.

## Solution

Set 0600 permissions on `cp-nvim.json` and `cookies.json` after every
write, pass credentials via stdin pipe instead of env var, and stop
emitting passwords in ndjson from Kattis/USACO `LoginResult` (CSES token
emission unchanged).
2026-03-07 18:14:34 -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
9727dccc6f
feat(commands): add tab completion for :CP open (#338)
## Problem

`:CP open` accepts `problem`, `contest`, and `standings` but offered no
tab completion for them.

## Solution

Add an `args[2] == 'open'` branch in the `plugin/cp.lua` completer
returning the three valid subcommands.
2026-03-06 16:14:58 -05:00
Barrett Ruth
4ef00afe66
feat(commands): add :CP <platform> signup subcommand (#337)
## Problem

No quick way to reach a platform's registration page from within Neovim.

## Solution

Add `signup` as a platform subcommand that calls `vim.ui.open` on the
platform's registration URL. URLs live in a new `SIGNUP_URLS` table in
`constants.lua`. Works even when the platform is disabled. Tab
completion and vimdoc updated.
2026-03-06 16:14:33 -05:00
Barrett Ruth
6c036a7b2e
fix: systematic context guards and full panel lifecycle (#317)
## Problem

The `CONTEST_ACTIONS` list in `handle_command` was a manually maintained
parallel of `ACTIONS` that had already drifted (`pick` was incorrectly
included, breaking `:CP pick` cold). `navigate_problem` only cancelled
the `'run'` panel on `next`/`prev`, leaving interactive and stress
terminals alive and in-flight `run_io_view` callbacks unguarded.
`pick` and `cache` also appeared twice in tab-completion when a contest
was active.

## Solution

Replace `CONTEST_ACTIONS` with a `requires_context` field on
`ParsedCommand`,
set at each parse-site in `parse_command` so the semantics live with the
action definition. Expand `navigate_problem` to call `cancel_io_view()`
and
dispatch `cancel_interactive`/`stress.cancel` for all panel types,
mirroring
the contest-switch logic. Filter already-present `pick` and `cache` from
the
context-conditional completion candidates.
2026-03-05 18:29:41 -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
Barrett Ruth
49e0ae3885
refactor(credentials): promote login/logout to top-level actions (#292)
## Problem

`:CP credentials login/logout/clear` is verbose and inconsistent with
other
actions that are all top-level (`:CP run`, `:CP submit`, etc.). The
clear-all
subcommand is also unnecessary since re-logging in overwrites existing
credentials.

## Solution

Replace `:CP credentials {login,logout,clear}` with `:CP login
[platform]`
and `:CP logout [platform]`. Remove the clear-all command and the
credentials
subcommand dispatch — login/logout are now regular actions routed
through the
standard action dispatcher.
2026-03-04 13:09:32 -05:00
Barrett Ruth
98ac0aa7a7
refactor(credentials): rename set/clear to login/logout/clear (#291)
## Problem

The `set` and `clear` subcommands don't clearly convey their intent —
`set`
reads like a generic setter rather than an auth action, and `clear`
overloads
single-platform and all-platform semantics in one subcommand.

## Solution

Rename `set` to `login`, split `clear` into `logout` (per-platform,
defaults
to active) and `clear` (all platforms).

New API:
- `:CP credentials login [platform]` — prompt and save credentials
- `:CP credentials logout [platform]` — remove credentials for one
platform
- `:CP credentials clear` — remove all stored credentials
2026-03-04 12:53:37 -05:00
a04702d87c refactor: replace :CP login with :CP credentials subcommand
Problem: :CP login was a poor API — no way to clear credentials without
raw Lua, and the single command didn't scale to multiple operations.

Solution: replace login with a :CP credentials subcommand following the
same pattern as :CP cache. :CP credentials set [platform] prompts and
saves; :CP credentials clear [platform] removes one or all platforms.
Add cache.clear_credentials(), rename login.lua to credentials.lua,
update parse/dispatch/tab-complete, and rewrite vimdoc accordingly.
2026-03-03 16:46:07 -05:00
3e0b7beabf feat: add :CP login command for explicit credential management
Problem: credentials were only set implicitly on first :CP submit.
There was no way to update wrong credentials, log out, or set
credentials ahead of time without editing the cache JSON manually.

Solution: add :CP login [platform] which always prompts for username
and password and overwrites any saved credentials for that platform.
Omitting the platform falls back to the active platform. Wire the
command through constants, parse_command, handle_command, and add
tab-completion (suggests platform names). Document in vimdoc under
the SUBMIT section and in the commands reference.
2026-03-03 16:28:54 -05:00
bfa2cf893c feat: wire race, stress, and submit commands and keymaps
Add command parsing and dispatch for :CP race, :CP race stop, :CP stress,
and :CP submit. Add tab-completion for race (platform/contest/--lang),
stress (cwd executables at arg 2 and 3), and race stop. Add
<Plug>(cp-stress), <Plug>(cp-submit), and <Plug>(cp-race-stop) keymaps.
2026-03-03 15:09:41 -05:00
029ea125b9 feat: add <Plug> mappings for all primary actions
Problem: users who want keybindings must call vim.cmd('CP run') or
reach into internal Lua modules directly. There is no stable,
discoverable, lazy-load-friendly public API for key binding.

Solution: define 7 <Plug> mappings in plugin/cp.lua that dispatch
through the same handle_command() code path as :CP. Document them
in a new MAPPINGS section in the vimdoc with helptags and an example
config block.
2026-02-07 13:23:45 -05:00
Barrett Ruth
4b1b75fd6e fix(config): padding spacing 2025-10-24 14:44:33 -04:00
Barrett Ruth
3daf582b7a feat(cache): update cache 2025-10-24 14:26:51 -04:00
Barrett Ruth
6ff0320531 cleanup 2025-10-24 13:48:56 -04:00
Barrett Ruth
9d848eba22 feat: improve autocomplete 2025-10-24 01:44:06 -04:00
41a8d1a75b feat: interactive mode 2025-10-05 15:36:28 -04:00
44bfc7317d feat(cli): :CP <problem_id> 2025-10-05 12:59:50 -04:00
6b8a1e2087 more docs 2025-10-01 21:36:53 -04:00
dc4326524c fix(health): simplify health check 2025-09-30 19:49:10 -04:00
05968657f5 feat: better auto-completion 2025-09-21 15:22:08 -04:00
cb4d39b4a7 feat(cache): auto-completion to the cli1 2025-09-21 15:20:13 -04:00
78071b119b feat: base testing files 2025-09-18 22:25:40 -04:00
bc315818e4 fix(ci): format 2025-09-18 20:04:36 -04:00
fb240fd501 feat: :CP test refactor 2025-09-18 10:20:20 -04:00
c99cf8d4f0 feat: atcoder scraper update for :CP test 2025-09-15 18:31:26 -04:00
d4fd02499d fix: revert stylua config 2025-09-15 18:10:35 -04:00
fe4cf2b680 feat(ci): use new stylua config 2025-09-15 18:10:11 -04:00
5d630d9dac refactor lang to constants 2025-09-15 18:07:22 -04:00
d43d8e4258 feat: remove diff mode 2025-09-15 15:30:26 -04:00
5417da9b52 feat: make autocomplete more sophisticated 2025-09-15 14:32:44 -04:00
35008bea32 try to fix snippets 2025-09-15 12:43:24 -04:00
20b058f034 better snippets, language management 2025-09-15 12:22:07 -04:00
95f4761b61 fix(ci): format 2025-09-15 11:35:29 -04:00
4aa16d2858 feat: flesh out language support 2025-09-15 11:35:22 -04:00
e10eab22d6 fix: revert multiple test cases 2025-09-15 10:37:40 -04:00
67d2a8054c feat: local state over vim.g 2025-09-15 07:05:31 -05:00
5cb7c03881 fix(ci): typing 2025-09-14 00:14:10 -05:00
2214c510a6 feat: nest all config in vim.g 2025-09-14 00:02:31 -05:00
08242fafa8 finish 2025-09-13 23:48:09 -05:00
40117c2cf1 feat: caching 2025-09-13 23:46:37 -05:00
94f5828a0a feat: modernize the plugin 2025-09-12 17:29:55 -05:00
0636757839 stylua no special config; 2025-09-11 23:59:02 -05:00
dcb7debff6 initial commit 2025-09-11 23:52:32 -05:00