## 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.
54 lines
1.2 KiB
Lua
54 lines
1.2 KiB
Lua
local M = {}
|
|
|
|
local config_module = require('cp.config')
|
|
local helpers = require('cp.helpers')
|
|
local logger = require('cp.log')
|
|
|
|
M.helpers = helpers
|
|
|
|
if vim.fn.has('nvim-0.10.0') == 0 then
|
|
logger.log('Requires nvim-0.10.0+', { level = vim.log.levels.ERROR })
|
|
return {}
|
|
end
|
|
|
|
local initialized = false
|
|
|
|
local function ensure_initialized()
|
|
if initialized then
|
|
return true
|
|
end
|
|
local user_config = vim.g.cp or {}
|
|
local ok, result = pcall(config_module.setup, user_config)
|
|
if not ok then
|
|
local msg = tostring(result):gsub('^.+:%d+: ', '')
|
|
logger.log(msg, { level = vim.log.levels.ERROR, override = true, sync = true })
|
|
return false
|
|
end
|
|
config_module.set_current_config(result)
|
|
initialized = true
|
|
return true
|
|
end
|
|
|
|
---@return nil
|
|
function M.handle_command(opts)
|
|
if not ensure_initialized() then
|
|
return
|
|
end
|
|
local commands = require('cp.commands')
|
|
commands.handle_command(opts)
|
|
end
|
|
|
|
function M.is_initialized()
|
|
return initialized
|
|
end
|
|
|
|
---@deprecated Use `vim.g.cp` instead
|
|
function M.setup(user_config)
|
|
vim.deprecate('require("cp").setup()', 'vim.g.cp', 'v0.7.7', 'cp.nvim', false)
|
|
|
|
if user_config then
|
|
vim.g.cp = vim.tbl_deep_extend('force', vim.g.cp or {}, user_config)
|
|
end
|
|
end
|
|
|
|
return M
|