Problem: AtCoder submit used a cookie fast-path that silently failed on stale sessions; `_LANGUAGE_ID_EXTENSION` only covered 2 of 116 languages; `LANGUAGE_VERSIONS` was incomplete for AtCoder, CF, and Kattis; AtCoder `prolog` and `racket` entries had wrong IDs. Raw `vim.notify` calls throughout bypassed `logger.log`, producing inconsistent or missing `[cp.nvim]:` prefixes. Solution: Remove cookie persistence from AtCoder login/submit — always use a fresh login within a single session. Increase `BROWSER_SUBMIT_NAV_TIMEOUT["atcoder"]` to 40s and switch to in-memory buffer upload with the correct per-language extension. Expand `LANGUAGE_VERSIONS` with all 116 AtCoder languages, 15 new CF languages with full version variants (java8/21, kotlin 1.7/1.9/2.2, rust 2021/2024, etc.), and 50+ Kattis languages. Fix AtCoder `prolog` ID (`6079`→`6081`, was Pony) and remove non-existent `racket` entry. Replace all raw `vim.notify` calls with `logger.log`.
90 lines
2.3 KiB
Lua
90 lines
2.3 KiB
Lua
local logger = require('cp.log')
|
|
local picker_utils = require('cp.pickers')
|
|
|
|
local M = {}
|
|
|
|
local function contest_picker(platform, refresh, language)
|
|
local constants = require('cp.constants')
|
|
local platform_display_name = constants.PLATFORM_DISPLAY_NAMES[platform]
|
|
local fzf = require('fzf-lua')
|
|
local contests = picker_utils.get_platform_contests(platform, refresh)
|
|
|
|
if vim.tbl_isempty(contests) then
|
|
logger.log(("No contests found for platform '%s'"):format(platform_display_name), { level = vim.log.levels.WARN })
|
|
return
|
|
end
|
|
|
|
local entries = vim.tbl_map(function(contest)
|
|
return contest.display_name
|
|
end, contests)
|
|
|
|
return fzf.fzf_exec(entries, {
|
|
prompt = ('Select Contest (%s)> '):format(platform_display_name),
|
|
fzf_opts = {
|
|
['--header'] = 'ctrl-r: refresh',
|
|
},
|
|
actions = {
|
|
['default'] = function(selected)
|
|
if vim.tbl_isempty(selected) then
|
|
return
|
|
end
|
|
|
|
local selected_name = selected[1]
|
|
local contest = nil
|
|
for _, c in ipairs(contests) do
|
|
if c.display_name == selected_name then
|
|
contest = c
|
|
break
|
|
end
|
|
end
|
|
|
|
if contest then
|
|
local cp = require('cp')
|
|
local fargs = { platform, contest.id }
|
|
if language then
|
|
table.insert(fargs, '--lang')
|
|
table.insert(fargs, language)
|
|
end
|
|
cp.handle_command({ fargs = fargs })
|
|
end
|
|
end,
|
|
['ctrl-r'] = function()
|
|
contest_picker(platform, true, language)
|
|
end,
|
|
},
|
|
})
|
|
end
|
|
|
|
function M.pick(language)
|
|
local fzf = require('fzf-lua')
|
|
local platforms = picker_utils.get_platforms()
|
|
local entries = vim.tbl_map(function(platform)
|
|
return platform.display_name
|
|
end, platforms)
|
|
|
|
return fzf.fzf_exec(entries, {
|
|
prompt = 'Select Platform> ',
|
|
actions = {
|
|
['default'] = function(selected)
|
|
if vim.tbl_isempty(selected) then
|
|
return
|
|
end
|
|
|
|
local selected_name = selected[1]
|
|
local platform = nil
|
|
for _, p in ipairs(platforms) do
|
|
if p.display_name == selected_name then
|
|
platform = p
|
|
break
|
|
end
|
|
end
|
|
|
|
if platform then
|
|
contest_picker(platform.id, false, language)
|
|
end
|
|
end,
|
|
},
|
|
})
|
|
end
|
|
|
|
return M
|