ci: format

This commit is contained in:
Barrett Ruth 2026-03-06 18:17:21 -05:00
parent 326e015f9b
commit 8b1f6b349f
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 28 additions and 9 deletions

View file

@ -55,13 +55,19 @@ function M.start(platform, contest_id, language)
local start_time = cache.get_contest_start_time(platform, contest_id) local start_time = cache.get_contest_start_time(platform, contest_id)
if not start_time then if not start_time then
logger.log('Fetching contest list...', { level = vim.log.levels.INFO, override = true, sync = true }) logger.log(
'Fetching contest list...',
{ level = vim.log.levels.INFO, override = true, sync = true }
)
local result = scraper.scrape_contest_list(platform) local result = scraper.scrape_contest_list(platform)
if result then if result then
local sc = result.supports_countdown local sc = result.supports_countdown
if sc == false then if sc == false then
cache.set_contest_summaries(platform, result.contests or {}, { supports_countdown = false }) cache.set_contest_summaries(platform, result.contests or {}, { supports_countdown = false })
logger.log(('%s does not support :CP race'):format(display), { level = vim.log.levels.ERROR }) logger.log(
('%s does not support :CP race'):format(display),
{ level = vim.log.levels.ERROR }
)
return return
end end
if result.contests and #result.contests > 0 then if result.contests and #result.contests > 0 then
@ -121,10 +127,7 @@ function M.start(platform, contest_id, language)
require('cp.setup').setup_contest(p, c, nil, l) require('cp.setup').setup_contest(p, c, nil, l)
else else
vim.notify( vim.notify(
('[cp.nvim] %s starts in %s'):format( ('[cp.nvim] %s starts in %s'):format(race_state.contest_name, format_countdown(r)),
race_state.contest_name,
format_countdown(r)
),
vim.log.levels.INFO vim.log.levels.INFO
) )
end end

View file

@ -109,6 +109,9 @@ end, {
end end
return filter_candidates(candidates) return filter_candidates(candidates)
elseif args[2] == 'race' then elseif args[2] == 'race' then
if require('cp.race').status().active then
return filter_candidates({ 'stop' })
end
local candidates = { 'stop' } local candidates = { 'stop' }
vim.list_extend(candidates, platforms) vim.list_extend(candidates, platforms)
return filter_candidates(candidates) return filter_candidates(candidates)
@ -126,7 +129,11 @@ end, {
if args[2] == 'stress' then if args[2] == 'stress' then
local utils = require('cp.utils') local utils = require('cp.utils')
return filter_candidates(utils.cwd_executables()) return filter_candidates(utils.cwd_executables())
elseif args[2] == 'race' and vim.tbl_contains(platforms, args[3]) then elseif
args[2] == 'race'
and not require('cp.race').status().active
and vim.tbl_contains(platforms, args[3])
then
local cache = require('cp.cache') local cache = require('cp.cache')
cache.load() cache.load()
local contests = cache.get_cached_contest_ids(args[3]) local contests = cache.get_cached_contest_ids(args[3])
@ -153,7 +160,11 @@ end, {
return filter_candidates(candidates) return filter_candidates(candidates)
end end
elseif num_args == 5 then elseif num_args == 5 then
if args[2] == 'race' and vim.tbl_contains(platforms, args[3]) then if
args[2] == 'race'
and not require('cp.race').status().active
and vim.tbl_contains(platforms, args[3])
then
return filter_candidates({ '--lang' }) return filter_candidates({ '--lang' })
elseif args[2] == 'cache' and args[3] == 'clear' and vim.tbl_contains(platforms, args[4]) then elseif args[2] == 'cache' and args[3] == 'clear' and vim.tbl_contains(platforms, args[4]) then
local cache = require('cp.cache') local cache = require('cp.cache')
@ -168,7 +179,12 @@ end, {
end end
end end
elseif num_args == 6 then elseif num_args == 6 then
if args[2] == 'race' and vim.tbl_contains(platforms, args[3]) and args[5] == '--lang' then if
args[2] == 'race'
and not require('cp.race').status().active
and vim.tbl_contains(platforms, args[3])
and args[5] == '--lang'
then
return filter_candidates(get_enabled_languages(args[3])) return filter_candidates(get_enabled_languages(args[3]))
elseif vim.tbl_contains(platforms, args[2]) and args[5] == '--lang' then elseif vim.tbl_contains(platforms, args[2]) and args[5] == '--lang' then
return filter_candidates(get_enabled_languages(args[2])) return filter_candidates(get_enabled_languages(args[2]))