ci: format
This commit is contained in:
parent
0e88e0f182
commit
72ea6249f4
3 changed files with 24 additions and 12 deletions
|
|
@ -169,15 +169,15 @@ M.defaults = {
|
||||||
hooks = {
|
hooks = {
|
||||||
setup = {
|
setup = {
|
||||||
contest = nil,
|
contest = nil,
|
||||||
code = nil,
|
code = nil,
|
||||||
io = {
|
io = {
|
||||||
input = helpers.clearcol,
|
input = helpers.clearcol,
|
||||||
output = helpers.clearcol,
|
output = helpers.clearcol,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on = {
|
on = {
|
||||||
enter = nil,
|
enter = nil,
|
||||||
run = nil,
|
run = nil,
|
||||||
debug = nil,
|
debug = nil,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -376,12 +376,12 @@ function M.setup(user_config)
|
||||||
vim.validate({ setup = { cfg.hooks.setup, 'table' } })
|
vim.validate({ setup = { cfg.hooks.setup, 'table' } })
|
||||||
vim.validate({
|
vim.validate({
|
||||||
contest = { cfg.hooks.setup.contest, { 'function', 'nil' }, true },
|
contest = { cfg.hooks.setup.contest, { 'function', 'nil' }, true },
|
||||||
code = { cfg.hooks.setup.code, { 'function', 'nil' }, true },
|
code = { cfg.hooks.setup.code, { 'function', 'nil' }, true },
|
||||||
})
|
})
|
||||||
if cfg.hooks.setup.io ~= nil then
|
if cfg.hooks.setup.io ~= nil then
|
||||||
vim.validate({ io = { cfg.hooks.setup.io, 'table' } })
|
vim.validate({ io = { cfg.hooks.setup.io, 'table' } })
|
||||||
vim.validate({
|
vim.validate({
|
||||||
input = { cfg.hooks.setup.io.input, { 'function', 'nil' }, true },
|
input = { cfg.hooks.setup.io.input, { 'function', 'nil' }, true },
|
||||||
output = { cfg.hooks.setup.io.output, { 'function', 'nil' }, true },
|
output = { cfg.hooks.setup.io.output, { 'function', 'nil' }, true },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
@ -390,7 +390,7 @@ function M.setup(user_config)
|
||||||
vim.validate({ on = { cfg.hooks.on, 'table' } })
|
vim.validate({ on = { cfg.hooks.on, 'table' } })
|
||||||
vim.validate({
|
vim.validate({
|
||||||
enter = { cfg.hooks.on.enter, { 'function', 'nil' }, true },
|
enter = { cfg.hooks.on.enter, { 'function', 'nil' }, true },
|
||||||
run = { cfg.hooks.on.run, { 'function', 'nil' }, true },
|
run = { cfg.hooks.on.run, { 'function', 'nil' }, true },
|
||||||
debug = { cfg.hooks.on.debug, { 'function', 'nil' }, true },
|
debug = { cfg.hooks.on.debug, { 'function', 'nil' }, true },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,9 @@ function M.setup_problem(problem_id, language)
|
||||||
local s = config.hooks and config.hooks.setup
|
local s = config.hooks and config.hooks.setup
|
||||||
if s and s.code then
|
if s and s.code then
|
||||||
local ok = pcall(s.code, state)
|
local ok = pcall(s.code, state)
|
||||||
if ok then vim.b[prov.bufnr].cp_setup_done = true end
|
if ok then
|
||||||
|
vim.b[prov.bufnr].cp_setup_done = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
helpers.clearcol(prov.bufnr)
|
helpers.clearcol(prov.bufnr)
|
||||||
vim.b[prov.bufnr].cp_setup_done = true
|
vim.b[prov.bufnr].cp_setup_done = true
|
||||||
|
|
@ -316,7 +318,9 @@ function M.setup_problem(problem_id, language)
|
||||||
local bufnr = prov.bufnr
|
local bufnr = prov.bufnr
|
||||||
vim.api.nvim_create_autocmd('BufEnter', {
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function() pcall(o.enter, state) end,
|
callback = function()
|
||||||
|
pcall(o.enter, state)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
pcall(o.enter, state)
|
pcall(o.enter, state)
|
||||||
end
|
end
|
||||||
|
|
@ -351,7 +355,9 @@ function M.setup_problem(problem_id, language)
|
||||||
local s = config.hooks and config.hooks.setup
|
local s = config.hooks and config.hooks.setup
|
||||||
if s and s.code then
|
if s and s.code then
|
||||||
local ok = pcall(s.code, state)
|
local ok = pcall(s.code, state)
|
||||||
if ok then vim.b[bufnr].cp_setup_done = true end
|
if ok then
|
||||||
|
vim.b[bufnr].cp_setup_done = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
helpers.clearcol(bufnr)
|
helpers.clearcol(bufnr)
|
||||||
vim.b[bufnr].cp_setup_done = true
|
vim.b[bufnr].cp_setup_done = true
|
||||||
|
|
@ -360,7 +366,9 @@ function M.setup_problem(problem_id, language)
|
||||||
if o and o.enter then
|
if o and o.enter then
|
||||||
vim.api.nvim_create_autocmd('BufEnter', {
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function() pcall(o.enter, state) end,
|
callback = function()
|
||||||
|
pcall(o.enter, state)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
pcall(o.enter, state)
|
pcall(o.enter, state)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -960,10 +960,14 @@ function M.toggle_panel(panel_opts)
|
||||||
|
|
||||||
local o = config.hooks and config.hooks.on
|
local o = config.hooks and config.hooks.on
|
||||||
if o and o.run then
|
if o and o.run then
|
||||||
vim.schedule(function() o.run(state) end)
|
vim.schedule(function()
|
||||||
|
o.run(state)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
if panel_opts and panel_opts.debug and o and o.debug then
|
if panel_opts and panel_opts.debug and o and o.debug then
|
||||||
vim.schedule(function() o.debug(state) end)
|
vim.schedule(function()
|
||||||
|
o.debug(state)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_set_current_win(test_windows.tab_win)
|
vim.api.nvim_set_current_win(test_windows.tab_win)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue