doc: update
This commit is contained in:
parent
72ea6249f4
commit
dc9cb10f3a
1 changed files with 51 additions and 29 deletions
|
|
@ -220,38 +220,60 @@ run CSES problems with Rust using the single schema:
|
||||||
|
|
||||||
*cp.Hooks*
|
*cp.Hooks*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
{before_run} (function, optional) Called before test panel opens.
|
{setup} (|cp.CpSetupHooks|, optional) One-time initialization hooks.
|
||||||
function(state: cp.State)
|
{on} (|cp.CpOnHooks|, optional) Recurring event hooks.
|
||||||
{before_debug} (function, optional) Called before debug build/run.
|
|
||||||
function(state: cp.State)
|
|
||||||
{setup_code} (function, optional) Called after source file is opened.
|
|
||||||
function(state: cp.State)
|
|
||||||
{setup_io_input} (function, optional) Called when I/O input buffer created.
|
|
||||||
function(bufnr: integer, state: cp.State)
|
|
||||||
Default: helpers.clearcol (removes line numbers/columns)
|
|
||||||
{setup_io_output} (function, optional) Called when I/O output buffer created.
|
|
||||||
function(bufnr: integer, state: cp.State)
|
|
||||||
Default: helpers.clearcol (removes line numbers/columns)
|
|
||||||
|
|
||||||
Hook functions receive the cp.nvim state object (|cp.State|). See
|
*cp.CpSetupHooks*
|
||||||
|
Fields: ~
|
||||||
|
{contest} (function, optional) Called once when a contest directory
|
||||||
|
is first created (not on subsequent visits).
|
||||||
|
function(state: cp.State)
|
||||||
|
{code} (function, optional) Called after the source buffer is
|
||||||
|
opened for the first time (guarded by cp_setup_done).
|
||||||
|
function(state: cp.State)
|
||||||
|
{io} (|cp.CpSetupIOHooks|, optional) I/O buffer hooks.
|
||||||
|
|
||||||
|
*cp.CpSetupIOHooks*
|
||||||
|
Fields: ~
|
||||||
|
{input} (function, optional) Called when the I/O input buffer is
|
||||||
|
created. function(bufnr: integer, state: cp.State)
|
||||||
|
Default: helpers.clearcol
|
||||||
|
{output} (function, optional) Called when the I/O output buffer is
|
||||||
|
created. function(bufnr: integer, state: cp.State)
|
||||||
|
Default: helpers.clearcol
|
||||||
|
|
||||||
|
*cp.CpOnHooks*
|
||||||
|
Fields: ~
|
||||||
|
{enter} (function, optional) Called on every BufEnter on the
|
||||||
|
solution buffer. Registered as a buffer-scoped autocmd and
|
||||||
|
fired immediately after setup.code.
|
||||||
|
function(state: cp.State)
|
||||||
|
{run} (function, optional) Called before the test panel opens.
|
||||||
|
function(state: cp.State)
|
||||||
|
{debug} (function, optional) Called before a debug run.
|
||||||
|
function(state: cp.State)
|
||||||
|
|
||||||
|
All hook functions receive the cp.nvim state object (|cp.State|). See
|
||||||
|lua/cp/state.lua| for available methods and fields.
|
|lua/cp/state.lua| for available methods and fields.
|
||||||
|
|
||||||
The I/O buffer hooks are called once when the buffers are first created
|
|
||||||
during problem setup. Use these to customize buffer appearance (e.g.,
|
|
||||||
remove line numbers, set custom options). Access helpers via:
|
|
||||||
>lua
|
|
||||||
local helpers = require('cp').helpers
|
|
||||||
<
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>lua
|
>lua
|
||||||
hooks = {
|
hooks = {
|
||||||
setup_code = function(state)
|
setup = {
|
||||||
print("Setting up " .. state.get_base_name())
|
contest = function(state)
|
||||||
print("Source file: " .. state.get_source_file())
|
local dir = vim.fn.fnamemodify(
|
||||||
end,
|
state.get_source_file(state.get_language()), ':h')
|
||||||
setup_io_input = function(bufnr, state)
|
vim.fn.system({ 'cp', '~/.clang-format', dir .. '/.clang-format' })
|
||||||
vim.api.nvim_set_option_value('number', false, { buf = bufnr })
|
end,
|
||||||
end
|
code = function(state)
|
||||||
|
vim.opt_local.foldmethod = 'marker'
|
||||||
|
vim.diagnostic.enable(false)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
on = {
|
||||||
|
enter = function(state) vim.opt_local.winbar = '' end,
|
||||||
|
run = function(state) require('config.lsp').format() end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
@ -657,9 +679,9 @@ While in the I/O view buffers, use the configured keymaps to cycle through tests
|
||||||
|
|
||||||
Buffer Customization ~
|
Buffer Customization ~
|
||||||
|
|
||||||
Use the setup_io_input and setup_io_output hooks (see |cp.Hooks|) to customize
|
Use the hooks.setup.io.input and hooks.setup.io.output hooks (see |cp.Hooks|)
|
||||||
buffer appearance. By default, line numbers and columns are removed via
|
to customize buffer appearance. By default, line numbers and columns are
|
||||||
helpers.clearcol (see |cp-helpers|).
|
removed via helpers.clearcol (see |cp-helpers|).
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
VERDICT FORMATTING *cp-verdict-format*
|
VERDICT FORMATTING *cp-verdict-format*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue