fix(ci): format
This commit is contained in:
parent
4aa16d2858
commit
95f4761b61
3 changed files with 24 additions and 7 deletions
|
|
@ -127,9 +127,14 @@ function M.setup(user_config)
|
||||||
for lang_name, lang_config in pairs(contest_config) do
|
for lang_name, lang_config in pairs(contest_config) do
|
||||||
if type(lang_config) == "table" and lang_config.extension then
|
if type(lang_config) == "table" and lang_config.extension then
|
||||||
if not vim.tbl_contains(vim.tbl_keys(filetype_to_language), lang_config.extension) then
|
if not vim.tbl_contains(vim.tbl_keys(filetype_to_language), lang_config.extension) then
|
||||||
error(("Invalid extension '%s' for language '%s' in contest '%s'. Valid extensions: %s"):format(
|
error(
|
||||||
lang_config.extension, lang_name, contest_name, table.concat(vim.tbl_keys(filetype_to_language), ", ")
|
("Invalid extension '%s' for language '%s' in contest '%s'. Valid extensions: %s"):format(
|
||||||
))
|
lang_config.extension,
|
||||||
|
lang_name,
|
||||||
|
contest_name,
|
||||||
|
table.concat(vim.tbl_keys(filetype_to_language), ", ")
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,10 @@ end
|
||||||
|
|
||||||
local function parse_command(args)
|
local function parse_command(args)
|
||||||
if #args == 0 then
|
if #args == 0 then
|
||||||
return { type = "error", message = "Usage: :CP <platform> <contest> [problem] [--lang=<language>] | :CP <action> | :CP <problem>" }
|
return {
|
||||||
|
type = "error",
|
||||||
|
message = "Usage: :CP <platform> <contest> [problem] [--lang=<language>] | :CP <action> | :CP <problem>",
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local language = nil
|
local language = nil
|
||||||
|
|
@ -344,7 +347,13 @@ local function parse_command(args)
|
||||||
return { type = "contest_setup", platform = first, contest = filtered_args[2], language = language }
|
return { type = "contest_setup", platform = first, contest = filtered_args[2], language = language }
|
||||||
end
|
end
|
||||||
elseif #filtered_args == 3 then
|
elseif #filtered_args == 3 then
|
||||||
return { type = "full_setup", platform = first, contest = filtered_args[2], problem = filtered_args[3], language = language }
|
return {
|
||||||
|
type = "full_setup",
|
||||||
|
platform = first,
|
||||||
|
contest = filtered_args[2],
|
||||||
|
problem = filtered_args[3],
|
||||||
|
language = language,
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return { type = "error", message = "Too many arguments" }
|
return { type = "error", message = "Too many arguments" }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,10 @@ end, {
|
||||||
num_args = num_args + 1
|
num_args = num_args + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local lang_flag_present = vim.tbl_contains(args, "--lang") or vim.iter(args):any(function(arg) return arg:match("^--lang=") end)
|
local lang_flag_present = vim.tbl_contains(args, "--lang")
|
||||||
|
or vim.iter(args):any(function(arg)
|
||||||
|
return arg:match("^--lang=")
|
||||||
|
end)
|
||||||
|
|
||||||
if num_args == 2 then
|
if num_args == 2 then
|
||||||
local candidates = { "--lang" }
|
local candidates = { "--lang" }
|
||||||
|
|
@ -63,7 +66,7 @@ end, {
|
||||||
return vim.tbl_filter(function(cmd)
|
return vim.tbl_filter(function(cmd)
|
||||||
return cmd:find(ArgLead, 1, true) == 1
|
return cmd:find(ArgLead, 1, true) == 1
|
||||||
end, candidates)
|
end, candidates)
|
||||||
elseif args[#args-1] == "--lang" then
|
elseif args[#args - 1] == "--lang" then
|
||||||
return vim.tbl_filter(function(lang)
|
return vim.tbl_filter(function(lang)
|
||||||
return lang:find(ArgLead, 1, true) == 1
|
return lang:find(ArgLead, 1, true) == 1
|
||||||
end, languages)
|
end, languages)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue