feat(commands): implement :CP open [problem|contest|standings] (#319)

## Problem

There was no way to open a problem, contest, or standings page in the
browser from within the plugin.

## Solution

Add `contest_url` and `standings_url` to `MetadataResult` and persist
them in the cache. Add `cache.get_open_urls` to resolve all three URLs.
Wire up `:CP open [problem|contest|standings]` in `commands/init.lua`
to call `vim.ui.open`, warning when a URL is unavailable (e.g. CSES
has no standings). Closes #315.
This commit is contained in:
Barrett Ruth 2026-03-05 19:16:05 -05:00 committed by GitHub
parent b959f29bd4
commit 7bf4cf2538
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 65 additions and 2 deletions

View file

@ -243,7 +243,14 @@ function M.setup_contest(platform, contest_id, problem_id, language)
contest_id,
vim.schedule_wrap(function(result)
local problems = result.problems or {}
cache.set_contest_data(platform, contest_id, problems, result.url)
cache.set_contest_data(
platform,
contest_id,
problems,
result.url,
result.contest_url or '',
result.standings_url or ''
)
local prov = state.get_provisional()
if not prov or prov.platform ~= platform or prov.contest_id ~= contest_id then
return