fix(test): update vimdocs
This commit is contained in:
parent
97873ffd37
commit
a8f16fb4f9
8 changed files with 126 additions and 79 deletions
153
doc/cp.txt
153
doc/cp.txt
|
|
@ -126,91 +126,87 @@ Here's an example configuration with lazy.nvim: >lua
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
*cp.Config*
|
*cp.Config*
|
||||||
|
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {contests} (`table<string,ContestConfig>`) Contest configurations.
|
{contests} (table<string,ContestConfig>) Contest configurations.
|
||||||
- {hooks} (`cp.Hooks`) Hook functions called at various stages.
|
{hooks} (|cp.Hooks|) Hook functions called at various stages.
|
||||||
- {snippets} (`table[]`) LuaSnip snippet definitions.
|
{snippets} (table[]) LuaSnip snippet definitions.
|
||||||
- {debug} (`boolean`, default: `false`) Show info messages
|
{debug} (boolean, default: false) Show info messages
|
||||||
during operation.
|
during operation.
|
||||||
- {scrapers} (`table<string>`) List of enabled scrapers.
|
{scrapers} (table<string>) List of enabled scrapers.
|
||||||
Default: all scrapers enabled
|
Default: all scrapers enabled
|
||||||
- {run_panel} (`RunPanelConfig`) Test panel behavior configuration.
|
{run_panel} (|RunPanelConfig|) Test panel behavior configuration.
|
||||||
- {diff} (`DiffConfig`) Diff backend configuration.
|
{diff} (|DiffConfig|) Diff backend configuration.
|
||||||
- {filename}? (`function`) Custom filename generation function.
|
{filename} (function, optional) Custom filename generation.
|
||||||
`function(contest, contest_id, problem_id, config, language)`
|
function(contest, contest_id, problem_id, config, language)
|
||||||
Should return full filename with extension.
|
Should return full filename with extension.
|
||||||
(default: `default_filename` - concatenates contest_id and problem_id, lowercased)
|
(default: concatenates contest_id and problem_id, lowercased)
|
||||||
|
|
||||||
*cp.ContestConfig*
|
|
||||||
|
|
||||||
|
*cp.ContestConfig*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {cpp} (`LanguageConfig`) C++ language configuration.
|
{cpp} (|LanguageConfig|) C++ language configuration.
|
||||||
- {python} (`LanguageConfig`) Python language configuration.
|
{python} (|LanguageConfig|) Python language configuration.
|
||||||
- {default_language} (`string`, default: `"cpp"`) Default language when
|
{default_language} (string, default: "cpp") Default language when
|
||||||
`--lang` not specified.
|
--lang not specified.
|
||||||
|
|
||||||
*cp.LanguageConfig*
|
|
||||||
|
|
||||||
|
*cp.LanguageConfig*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {compile}? (`string[]`) Compile command template with
|
{compile} (string[], optional) Compile command template with
|
||||||
`{version}`, `{source}`, `{binary}` placeholders.
|
{version}, {source}, {binary} placeholders.
|
||||||
- {test} (`string[]`) Test execution command template.
|
{test} (string[]) Test execution command template.
|
||||||
- {debug}? (`string[]`) Debug compile command template.
|
{debug} (string[], optional) Debug compile command template.
|
||||||
- {version}? (`number`) Language version (e.g. 20, 23 for C++).
|
{version} (number, optional) Language version (e.g. 20, 23 for C++).
|
||||||
- {extension} (`string`) File extension (e.g. "cc", "py").
|
{extension} (string) File extension (e.g. "cc", "py").
|
||||||
- {executable}? (`string`) Executable name for interpreted languages.
|
{executable} (string, optional) Executable name for interpreted languages.
|
||||||
|
|
||||||
*cp.RunPanelConfig*
|
|
||||||
|
|
||||||
|
*cp.RunPanelConfig*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {diff_mode} (`string`, default: `"vim"`) Diff backend: "vim" or "git".
|
{diff_mode} (string, default: "vim") Diff backend: "vim" or "git".
|
||||||
Git provides character-level precision, vim uses built-in diff.
|
Git provides character-level precision, vim uses
|
||||||
- {next_test_key} (`string`, default: `"<c-n>"`) Key to navigate to next test case.
|
built-in diff.
|
||||||
- {prev_test_key} (`string`, default: `"<c-p>"`) Key to navigate to previous test case.
|
{next_test_key} (string, default: "<c-n>") Key to navigate to next test case.
|
||||||
- {toggle_diff_key} (`string`, default: `"t"`) Key to toggle diff mode between vim and git.
|
{prev_test_key} (string, default: "<c-p>") Key to navigate to previous test case.
|
||||||
- {max_output_lines} (`number`, default: `50`) Maximum lines of test output to display.
|
{toggle_diff_key} (string, default: "t") Key to toggle diff mode.
|
||||||
|
{max_output_lines} (number, default: 50) Maximum lines of test output.
|
||||||
*cp.DiffConfig*
|
|
||||||
|
|
||||||
|
*cp.DiffConfig*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {git} (`DiffGitConfig`) Git diff backend configuration.
|
{git} (|DiffGitConfig|) Git diff backend configuration.
|
||||||
|
|
||||||
*cp.Hooks*
|
|
||||||
|
|
||||||
|
*cp.Hooks*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {before_run}? (`function`) Called before test panel opens.
|
{before_run} (function, optional) Called before test panel opens.
|
||||||
`function(ctx: ProblemContext)`
|
function(ctx: ProblemContext)
|
||||||
- {before_debug}? (`function`) Called before debug compilation.
|
{before_debug} (function, optional) Called before debug compilation.
|
||||||
`function(ctx: ProblemContext)`
|
function(ctx: ProblemContext)
|
||||||
- {setup_code}? (`function`) Called after source file is opened.
|
{setup_code} (function, optional) Called after source file is opened.
|
||||||
Good for configuring buffer settings.
|
Good for configuring buffer settings.
|
||||||
`function(ctx: ProblemContext)`
|
function(ctx: ProblemContext)
|
||||||
|
|
||||||
*ProblemContext*
|
|
||||||
|
|
||||||
|
*ProblemContext*
|
||||||
Fields: ~
|
Fields: ~
|
||||||
- {contest} (`string`) Platform name (e.g. "atcoder", "codeforces")
|
{contest} (string) Platform name (e.g. "atcoder", "codeforces")
|
||||||
- {contest_id} (`string`) Contest ID (e.g. "abc123", "1933")
|
{contest_id} (string) Contest ID (e.g. "abc123", "1933")
|
||||||
- {problem_id}? (`string`) Problem ID (e.g. "a", "b") - nil for CSES
|
{problem_id} (string, optional) Problem ID (e.g. "a", "b") - nil for CSES
|
||||||
- {source_file} (`string`) Source filename (e.g. "abc123a.cpp")
|
{source_file} (string) Source filename (e.g. "abc123a.cpp")
|
||||||
- {binary_file} (`string`) Binary output path (e.g. "build/abc123a.run")
|
{binary_file} (string) Binary output path (e.g. "build/abc123a.run")
|
||||||
- {input_file} (`string`) Test input path (e.g. "io/abc123a.cpin")
|
{input_file} (string) Test input path (e.g. "io/abc123a.cpin")
|
||||||
- {output_file} (`string`) Program output path (e.g. "io/abc123a.cpout")
|
{output_file} (string) Program output path (e.g. "io/abc123a.cpout")
|
||||||
- {expected_file} (`string`) Expected output path (e.g. "io/abc123a.expected")
|
{expected_file} (string) Expected output path (e.g. "io/abc123a.expected")
|
||||||
- {problem_name} (`string`) Display name (e.g. "abc123a")
|
{problem_name} (string) Display name (e.g. "abc123a")
|
||||||
|
|
||||||
WORKFLOW *cp-workflow*
|
==============================================================================
|
||||||
|
WORKFLOW *cp-workflow*
|
||||||
|
|
||||||
For the sake of consistency and simplicity, cp.nvim extracts contest/problem identifiers from
|
For the sake of consistency and simplicity, cp.nvim extracts contest/problem
|
||||||
URLs. This means that, for example, CodeForces/AtCoder contests are configured by
|
identifiers from URLs. This means that, for example, CodeForces/AtCoder
|
||||||
their round id rather than round number. See below.
|
contests are configured by their round id rather than round number. See below.
|
||||||
|
|
||||||
PLATFORM-SPECIFIC USAGE *cp-platforms*
|
==============================================================================
|
||||||
|
PLATFORM-SPECIFIC USAGE *cp-platforms*
|
||||||
|
|
||||||
AtCoder ~
|
AtCoder ~
|
||||||
*cp-atcoder*
|
*cp-atcoder*
|
||||||
URL format: https://atcoder.jp/contests/abc123/tasks/abc123_a
|
URL format: https://atcoder.jp/contests/abc123/tasks/abc123_a
|
||||||
|
|
||||||
In terms of cp.nvim, this corresponds to:
|
In terms of cp.nvim, this corresponds to:
|
||||||
|
|
@ -224,8 +220,9 @@ Usage examples: >
|
||||||
:CP b " Switch to problem B (if contest loaded)
|
:CP b " Switch to problem B (if contest loaded)
|
||||||
:CP next " Navigate to next problem in contest
|
:CP next " Navigate to next problem in contest
|
||||||
<
|
<
|
||||||
|
|
||||||
Codeforces ~
|
Codeforces ~
|
||||||
*cp-codeforces*
|
*cp-codeforces*
|
||||||
URL format: https://codeforces.com/contest/1234/problem/A
|
URL format: https://codeforces.com/contest/1234/problem/A
|
||||||
|
|
||||||
In terms of cp.nvim, this corresponds to:
|
In terms of cp.nvim, this corresponds to:
|
||||||
|
|
@ -239,8 +236,9 @@ Usage examples: >
|
||||||
:CP c " Switch to problem C (if contest loaded)
|
:CP c " Switch to problem C (if contest loaded)
|
||||||
:CP prev " Navigate to previous problem in contest
|
:CP prev " Navigate to previous problem in contest
|
||||||
<
|
<
|
||||||
|
|
||||||
CSES ~
|
CSES ~
|
||||||
*cp-cses*
|
*cp-cses*
|
||||||
URL format: https://cses.fi/problemset/task/1068
|
URL format: https://cses.fi/problemset/task/1068
|
||||||
|
|
||||||
CSES is organized by categories rather than contests. Currently all problems
|
CSES is organized by categories rather than contests. Currently all problems
|
||||||
|
|
@ -256,21 +254,22 @@ Usage examples: >
|
||||||
:CP 1070 " Switch to problem 1070 (if CSES loaded)
|
:CP 1070 " Switch to problem 1070 (if CSES loaded)
|
||||||
:CP next " Navigate to next problem in CSES
|
:CP next " Navigate to next problem in CSES
|
||||||
<
|
<
|
||||||
COMPLETE WORKFLOW EXAMPLE *cp-example*
|
==============================================================================
|
||||||
|
COMPLETE WORKFLOW EXAMPLE *cp-example*
|
||||||
|
|
||||||
Example: Setting up and solving AtCoder contest ABC324
|
Example: Setting up and solving AtCoder contest ABC324
|
||||||
|
|
||||||
1. Browse to https://atcoder.jp/contests/abc324
|
1. Browse to https://atcoder.jp/contests/abc324
|
||||||
|
|
||||||
2. Set up contest and load metadata: >
|
2. Set up contest and load metadata: >
|
||||||
:CP atcoder abc324
|
:CP atcoder abc324
|
||||||
< This caches all problems (A, B, ...) for navigation
|
< This caches all problems (A, B, ...) for navigation
|
||||||
|
|
||||||
3. Start with problem A: >
|
3. Start with problem A: >
|
||||||
:CP a
|
:CP a
|
||||||
|
<
|
||||||
Or do both at once with:
|
Or do both at once with: >
|
||||||
:CP atcoder abc324 a
|
:CP atcoder abc324 a
|
||||||
|
|
||||||
< This creates a.cc and scrapes test cases
|
< This creates a.cc and scrapes test cases
|
||||||
|
|
||||||
4. Code your solution, then test: >
|
4. Code your solution, then test: >
|
||||||
|
|
@ -281,27 +280,29 @@ Example: Setting up and solving AtCoder contest ABC324
|
||||||
5. If needed, debug with sanitizers: >
|
5. If needed, debug with sanitizers: >
|
||||||
:CP run --debug
|
:CP run --debug
|
||||||
<
|
<
|
||||||
|
|
||||||
6. Move to next problem: >
|
6. Move to next problem: >
|
||||||
:CP next
|
:CP next
|
||||||
< This automatically sets up problem B
|
< This automatically sets up problem B
|
||||||
|
|
||||||
6. Continue solving problems with :CP next/:CP prev navigation
|
7. Continue solving problems with :CP next/:CP prev navigation
|
||||||
7. Switch to another file (e.g., previous contest): >
|
|
||||||
|
8. Switch to another file (e.g., previous contest): >
|
||||||
:e ~/contests/abc323/a.cpp
|
:e ~/contests/abc323/a.cpp
|
||||||
:CP
|
:CP
|
||||||
< Automatically restores abc323 contest context
|
< Automatically restores abc323 contest context
|
||||||
|
|
||||||
8. Submit solutions on AtCoder website
|
9. Submit solutions on AtCoder website
|
||||||
<
|
|
||||||
|
|
||||||
RUN PANEL *cp-run*
|
==============================================================================
|
||||||
|
RUN PANEL *cp-run*
|
||||||
|
|
||||||
The run panel provides individual test case debugging with a streamlined
|
The run panel provides individual test case debugging with a streamlined
|
||||||
layout optimized for modern screens. Shows test status with competitive
|
layout optimized for modern screens. Shows test status with competitive
|
||||||
programming terminology and efficient space usage.
|
programming terminology and efficient space usage.
|
||||||
|
|
||||||
Activation ~
|
Activation ~
|
||||||
*:CP-run*
|
*:CP-run*
|
||||||
:CP run [--debug] Toggle run panel on/off. When activated,
|
:CP run [--debug] Toggle run panel on/off. When activated,
|
||||||
replaces current layout with test interface.
|
replaces current layout with test interface.
|
||||||
Automatically compiles and runs all tests.
|
Automatically compiles and runs all tests.
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
describe('cp.cache', function()
|
describe('cp.cache', function()
|
||||||
local cache
|
local cache
|
||||||
|
local spec_helper = require('spec.spec_helper')
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
spec_helper.setup()
|
||||||
cache = require('cp.cache')
|
cache = require('cp.cache')
|
||||||
cache.load()
|
cache.load()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
cache.clear_contest_data('atcoder', 'test_contest')
|
cache.clear_contest_data('atcoder', 'test_contest')
|
||||||
cache.clear_contest_data('codeforces', 'test_contest')
|
cache.clear_contest_data('codeforces', 'test_contest')
|
||||||
cache.clear_contest_data('cses', 'test_contest')
|
cache.clear_contest_data('cses', 'test_contest')
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
describe('cp.config', function()
|
describe('cp.config', function()
|
||||||
local config
|
local config
|
||||||
|
local spec_helper = require('spec.spec_helper')
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
spec_helper.setup()
|
||||||
config = require('cp.config')
|
config = require('cp.config')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
|
end)
|
||||||
|
|
||||||
describe('setup', function()
|
describe('setup', function()
|
||||||
it('returns defaults with nil input', function()
|
it('returns defaults with nil input', function()
|
||||||
local result = config.setup()
|
local result = config.setup()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
describe('cp.diff', function()
|
describe('cp.diff', function()
|
||||||
local diff = require('cp.diff')
|
local spec_helper = require('spec.spec_helper')
|
||||||
|
local diff
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
spec_helper.setup()
|
||||||
|
diff = require('cp.diff')
|
||||||
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
|
end)
|
||||||
|
|
||||||
describe('get_available_backends', function()
|
describe('get_available_backends', function()
|
||||||
it('returns vim and git backends', function()
|
it('returns vim and git backends', function()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
describe('cp.highlight', function()
|
describe('cp.highlight', function()
|
||||||
local highlight = require('cp.highlight')
|
local spec_helper = require('spec.spec_helper')
|
||||||
|
local highlight
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
spec_helper.setup()
|
||||||
|
highlight = require('cp.highlight')
|
||||||
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
|
end)
|
||||||
|
|
||||||
describe('parse_git_diff', function()
|
describe('parse_git_diff', function()
|
||||||
it('skips git diff headers', function()
|
it('skips git diff headers', function()
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
describe('cp.problem', function()
|
describe('cp.problem', function()
|
||||||
local problem
|
local problem
|
||||||
|
local spec_helper = require('spec.spec_helper')
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
spec_helper.setup()
|
||||||
problem = require('cp.problem')
|
problem = require('cp.problem')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
|
end)
|
||||||
|
|
||||||
describe('create_context', function()
|
describe('create_context', function()
|
||||||
local base_config = {
|
local base_config = {
|
||||||
contests = {
|
contests = {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ describe('cp.snippets', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
package.loaded['luasnip'] = nil
|
package.loaded['luasnip'] = nil
|
||||||
package.loaded['luasnip.extras.fmt'] = nil
|
package.loaded['luasnip.extras.fmt'] = nil
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
describe('cp.test_render', function()
|
describe('cp.test_render', function()
|
||||||
local test_render = require('cp.test_render')
|
local spec_helper = require('spec.spec_helper')
|
||||||
|
local test_render
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
spec_helper.setup()
|
||||||
|
test_render = require('cp.test_render')
|
||||||
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
spec_helper.teardown()
|
||||||
|
end)
|
||||||
|
|
||||||
describe('get_status_info', function()
|
describe('get_status_info', function()
|
||||||
it('returns AC for pass status', function()
|
it('returns AC for pass status', function()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue