doc cleanups
This commit is contained in:
parent
b68ecbbe96
commit
f5a72a3a8f
4 changed files with 47 additions and 57 deletions
|
|
@ -51,8 +51,6 @@ COMMANDS *cp-commands*
|
||||||
:CP run Toggle run panel for individual test cases.
|
:CP run Toggle run panel for individual test cases.
|
||||||
Shows per-test results with redesigned
|
Shows per-test results with redesigned
|
||||||
layout for efficient comparison.
|
layout for efficient comparison.
|
||||||
Use --debug flag to compile with debug flags.
|
|
||||||
Requires contest setup first.
|
|
||||||
|
|
||||||
:CP debug
|
:CP debug
|
||||||
Same as above but with the debug mode configured
|
Same as above but with the debug mode configured
|
||||||
|
|
@ -80,20 +78,6 @@ COMMANDS *cp-commands*
|
||||||
View the cache in a pretty-printed lua buffer.
|
View the cache in a pretty-printed lua buffer.
|
||||||
Exit with q.
|
Exit with q.
|
||||||
|
|
||||||
Command Flags ~
|
|
||||||
*cp-flags*
|
|
||||||
Flags can be used with setup and action commands:
|
|
||||||
|
|
||||||
--debug Use the debug command template.
|
|
||||||
For compiled languages, this selects
|
|
||||||
`commands.debug` (a debug *build*) instead of
|
|
||||||
`commands.build`. For interpreted languages,
|
|
||||||
this selects `commands.debug` in place of
|
|
||||||
`commands.run`.
|
|
||||||
Example: >
|
|
||||||
:CP run --debug
|
|
||||||
<
|
|
||||||
|
|
||||||
Template Variables ~
|
Template Variables ~
|
||||||
*cp-template-vars*
|
*cp-template-vars*
|
||||||
Command templates support variable substitution using `{variable}` syntax:
|
Command templates support variable substitution using `{variable}` syntax:
|
||||||
|
|
@ -355,22 +339,18 @@ Example: Setting up and solving AtCoder contest ABC324
|
||||||
< Navigate with j/k, run specific tests with <enter>
|
< Navigate with j/k, run specific tests with <enter>
|
||||||
Exit test panel with q or :CP run when done
|
Exit test panel with q or :CP run when done
|
||||||
|
|
||||||
5. If needed, debug with sanitizers: >
|
5. Move to next problem: >
|
||||||
:CP run --debug
|
|
||||||
<
|
|
||||||
|
|
||||||
6. Move to next problem: >
|
|
||||||
:CP next
|
:CP next
|
||||||
< This automatically sets up problem B
|
< This automatically sets up problem B
|
||||||
|
|
||||||
7. Continue solving problems with :CP next/:CP prev navigation
|
6. Continue solving problems with :CP next/:CP prev navigation
|
||||||
|
|
||||||
8. Switch to another file (e.g. previous contest): >
|
7. 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
|
||||||
|
|
||||||
9. Submit solutions on AtCoder website
|
8. Submit solutions on AtCoder website
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
PICKER INTEGRATION *cp-picker*
|
PICKER INTEGRATION *cp-picker*
|
||||||
|
|
@ -392,18 +372,9 @@ PICKER KEYMAPS *cp-picker-keys*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
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. Problem time/memory
|
||||||
layout optimized for modern screens. Shows test status with competitive
|
limit constraints are in columns Time/Mem respectively. Used time/memory are
|
||||||
programming terminology and efficient space usage.
|
in columns Runtime/RSS respectively.
|
||||||
|
|
||||||
Activation ~
|
|
||||||
*:CP-run*
|
|
||||||
:CP run [--debug] Toggle run panel on/off. When activated,
|
|
||||||
replaces current layout with test interface.
|
|
||||||
Automatically compiles and runs all tests.
|
|
||||||
Use --debug flag to compile with debug symbols
|
|
||||||
and sanitizers. Toggle again to restore original
|
|
||||||
layout.
|
|
||||||
|
|
||||||
Interface ~
|
Interface ~
|
||||||
|
|
||||||
|
|
@ -437,7 +408,7 @@ Test cases use competitive programming terminology with color highlighting:
|
||||||
TLE Time Limit Exceeded (timeout)
|
TLE Time Limit Exceeded (timeout)
|
||||||
MLE Memory Limit Exceeded Error (heuristic)
|
MLE Memory Limit Exceeded Error (heuristic)
|
||||||
RTE Runtime Error (other non-zero exit code)
|
RTE Runtime Error (other non-zero exit code)
|
||||||
NA Any other state (undecipherable, error, running)
|
NA Any other state
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
@ -446,13 +417,28 @@ ANSI COLORS AND HIGHLIGHTING *cp-ansi*
|
||||||
cp.nvim provides comprehensive ANSI color support and highlighting for
|
cp.nvim provides comprehensive ANSI color support and highlighting for
|
||||||
compiler output, program stderr, and diff visualization.
|
compiler output, program stderr, and diff visualization.
|
||||||
|
|
||||||
|
If you cannot see color highlighting in your config, it is likely due to an
|
||||||
|
erroneous config. Most tools (GCC, Python, Clang, Rustc) color stdout based on
|
||||||
|
whether stdout is connected to a terminal. One can usually get aorund this by
|
||||||
|
leveraging flags to force colored output. For example, to force colors with GCC,
|
||||||
|
alter your config as follows:
|
||||||
|
|
||||||
|
{
|
||||||
|
commands = {
|
||||||
|
build = {
|
||||||
|
'g++',
|
||||||
|
'-fdiagnostics-color=always',
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
HIGHLIGHT GROUPS *cp-highlights*
|
HIGHLIGHT GROUPS *cp-highlights*
|
||||||
|
|
||||||
Test Status Groups ~
|
Test Status Groups ~
|
||||||
|
|
||||||
Test cases use competitive programming terminology with color highlighting:
|
|
||||||
|
|
||||||
CpTestAC Green foreground for AC status
|
CpTestAC Green foreground for AC status
|
||||||
CpTestWA Red foreground for WA status
|
CpTestWA Red foreground for WA status
|
||||||
CpTestTLE Orange foreground for TLE status
|
CpTestTLE Orange foreground for TLE status
|
||||||
|
|
@ -498,24 +484,19 @@ Example combinations:
|
||||||
|
|
||||||
Diff Highlighting ~
|
Diff Highlighting ~
|
||||||
|
|
||||||
Diff visualization uses Neovim's built-in highlight groups that automatically
|
The git diff backend uses Neovim's built-in highlight groups that automatically
|
||||||
adapt to your colorscheme:
|
adapt to your colorscheme:
|
||||||
|
|
||||||
DiffAdd Highlights added text in git diffs
|
DiffAdd Highlights added text in git diffs
|
||||||
DiffDelete Highlights removed text in git diffs
|
DiffDelete Highlights removed text in git diffs
|
||||||
|
|
||||||
These groups are automatically used by the git diff backend for character-level
|
|
||||||
difference visualization with optimal colorscheme integration.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
TERMINAL COLOR INTEGRATION *cp-terminal-colors*
|
TERMINAL COLOR INTEGRATION *cp-terminal-colors*
|
||||||
|
|
||||||
ANSI colors automatically use your terminal's color palette through Neovim's
|
ANSI colors automatically use the terminal's color palette through Neovim's
|
||||||
vim.g.terminal_color_* variables. This ensures compiler colors match your
|
vim.g.terminal_color_* variables.
|
||||||
colorscheme without manual configuration.
|
|
||||||
|
|
||||||
If your colorscheme doesn't set terminal colors, cp.nvim will warn you and
|
If your colorscheme doesn't set terminal colors, set them like so: >vim
|
||||||
ANSI colors won't display properly - set them like so: >vim
|
|
||||||
let g:terminal_color_1 = '#ff6b6b'
|
let g:terminal_color_1 = '#ff6b6b'
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
@ -546,6 +527,7 @@ prevent them from being overridden: >lua
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
RUN PANEL KEYMAPS *cp-test-keys*
|
RUN PANEL KEYMAPS *cp-test-keys*
|
||||||
|
|
||||||
<c-n> Navigate to next test case
|
<c-n> Navigate to next test case
|
||||||
<c-p> Navigate to previous test case
|
<c-p> Navigate to previous test case
|
||||||
t Cycle through diff modes: none → git → vim
|
t Cycle through diff modes: none → git → vim
|
||||||
|
|
@ -554,27 +536,27 @@ q Exit run panel and restore layout
|
||||||
|
|
||||||
Diff Modes ~
|
Diff Modes ~
|
||||||
|
|
||||||
Two diff backends are available:
|
Three diff backends are available:
|
||||||
|
|
||||||
|
none Nothing
|
||||||
vim Built-in vim diff (default, always available)
|
vim Built-in vim diff (default, always available)
|
||||||
git Character-level git word-diff (requires git, more precise)
|
git Character-level git word-diff (requires git, more precise)
|
||||||
|
|
||||||
The git backend shows character-level changes with [-removed-] and {+added+}
|
The git backend shows character-level changes with [-removed-] and {+added+}
|
||||||
markers for precise difference analysis.
|
markers.
|
||||||
|
|
||||||
Execution Details ~
|
Execution Details ~
|
||||||
|
|
||||||
Test cases are executed individually using the same compilation and
|
Test cases are executed individually using the same compilation and
|
||||||
execution pipeline, but with isolated input/output for
|
execution pipeline, but with isolated input/output for
|
||||||
precise failure analysis. All tests are automatically run when the
|
precise failure analysis.
|
||||||
panel opens.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
FILE STRUCTURE *cp-files*
|
FILE STRUCTURE *cp-files*
|
||||||
|
|
||||||
cp.nvim creates the following file structure upon problem setup: >
|
cp.nvim creates the following file structure upon problem setup: >
|
||||||
|
|
||||||
{problem_id}.{ext} " Source file (e.g. a.cc, b.py)
|
{problem_id}.{ext} " Source file
|
||||||
build/
|
build/
|
||||||
{problem_id}.run " Compiled binary
|
{problem_id}.run " Compiled binary
|
||||||
io/
|
io/
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ function M.handle_command(opts)
|
||||||
if cmd.action == 'interact' then
|
if cmd.action == 'interact' then
|
||||||
ui.toggle_interactive()
|
ui.toggle_interactive()
|
||||||
elseif cmd.action == 'run' then
|
elseif cmd.action == 'run' then
|
||||||
ui.toggle_run_panel()
|
ui.toggle_run_panel({ debug = false })
|
||||||
elseif cmd.action == 'debug' then
|
elseif cmd.action == 'debug' then
|
||||||
ui.toggle_run_panel({ debug = true })
|
ui.toggle_run_panel({ debug = true })
|
||||||
elseif cmd.action == 'next' then
|
elseif cmd.action == 'next' then
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ function M.get_base_name()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.get_language()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
function M.get_source_file(language)
|
function M.get_source_file(language)
|
||||||
local base_name = M.get_base_name()
|
local base_name = M.get_base_name()
|
||||||
if not base_name or not M.get_platform() then
|
if not base_name or not M.get_platform() then
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ function M.toggle_interactive()
|
||||||
state.set_active_panel('interactive')
|
state.set_active_panel('interactive')
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param run_opts? RunOpts
|
---@param run_opts RunOpts
|
||||||
function M.toggle_run_panel(run_opts)
|
function M.toggle_run_panel(run_opts)
|
||||||
if state.get_active_panel() == 'run' then
|
if state.get_active_panel() == 'run' then
|
||||||
if current_diff_layout then
|
if current_diff_layout then
|
||||||
|
|
@ -270,10 +270,14 @@ function M.toggle_run_panel(run_opts)
|
||||||
setup_keybindings_for_buffer(test_buffers.tab_buf)
|
setup_keybindings_for_buffer(test_buffers.tab_buf)
|
||||||
|
|
||||||
if config.hooks and config.hooks.before_run then
|
if config.hooks and config.hooks.before_run then
|
||||||
config.hooks.before_run(state)
|
vim.schedule_wrap(function()
|
||||||
|
config.hooks.before_run(state)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
if run_opts.debug and config.hooks and config.hooks.before_debug then
|
if run_opts.debug and config.hooks and config.hooks.before_debug then
|
||||||
config.hooks.before_debug(state)
|
vim.schedule_wrap(function()
|
||||||
|
config.hooks.before_debug(state)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local execute = require('cp.runner.execute')
|
local execute = require('cp.runner.execute')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue