fix(docs): update for new features
This commit is contained in:
parent
60e5aabd99
commit
f45926c094
2 changed files with 163 additions and 68 deletions
23
README.md
23
README.md
|
|
@ -2,22 +2,28 @@
|
|||
|
||||
**The definitive competitive programming environment for Neovim**
|
||||
|
||||
Scrape problems, run tests, and debug solutions across multiple platforms with zero configuration.
|
||||
Scrape problems, run tests, and debug solutions across multiple platforms with
|
||||
zero configuration.
|
||||
|
||||
https://github.com/user-attachments/assets/50b19481-8e6d-47b4-bebc-15e16c61a9c9
|
||||
|
||||
## Features
|
||||
|
||||
- **Multi-platform support**: AtCoder, Codeforces, CSES with consistent interface
|
||||
- **Multi-platform support**: AtCoder, Codeforces, CSES with consistent
|
||||
interface
|
||||
- **Automatic problem setup**: Scrape test cases and metadata in seconds
|
||||
- **Rich test output**: 256 color ANSI support for compiler errors and program output
|
||||
- **Dual view modes**: Lightweight I/O view for quick feedback, full panel for
|
||||
detailed analysis
|
||||
- **Rich test output**: 256 color ANSI support for compiler errors and program
|
||||
output
|
||||
- **Language agnostic**: Works with any language
|
||||
- **Diff viewer**: Compare expected vs actual output with 3 diff modes
|
||||
|
||||
## Optional Dependencies
|
||||
|
||||
- [uv](https://docs.astral.sh/uv/) for problem scraping
|
||||
- GNU [time](https://www.gnu.org/software/time/) and [timeout](https://www.gnu.org/software/coreutils/manual/html_node/timeout-invocation.html)
|
||||
- GNU [time](https://www.gnu.org/software/time/) and
|
||||
[timeout](https://www.gnu.org/software/coreutils/manual/html_node/timeout-invocation.html)
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
|
@ -32,10 +38,11 @@ cp.nvim follows a simple principle: **solve locally, submit remotely**.
|
|||
:CP codeforces 1848
|
||||
```
|
||||
|
||||
3. **Code and test** with instant feedback and rich diffs
|
||||
3. **Code and test** with instant feedback
|
||||
|
||||
```
|
||||
:CP run
|
||||
:CP run " Quick verdict summary in splits
|
||||
:CP panel " Detailed analysis with diffs
|
||||
```
|
||||
|
||||
4. **Navigate between problems**
|
||||
|
|
@ -54,7 +61,9 @@ cp.nvim follows a simple principle: **solve locally, submit remotely**.
|
|||
:help cp.nvim
|
||||
```
|
||||
|
||||
See [my config](https://github.com/barrett-ruth/dots/blob/main/nvim/lua/plugins/cp.lua) for a relatively advanced setup.
|
||||
See
|
||||
[my config](https://github.com/barrett-ruth/dots/blob/main/nvim/lua/plugins/cp.lua)
|
||||
for a relatively advanced setup.
|
||||
|
||||
## Similar Projects
|
||||
|
||||
|
|
|
|||
134
doc/cp.nvim.txt
134
doc/cp.nvim.txt
|
|
@ -38,14 +38,23 @@ COMMANDS *cp-commands*
|
|||
Example: >
|
||||
:CP atcoder abc324
|
||||
<
|
||||
Action Commands ~
|
||||
:CP run Toggle run panel for individual test cases.
|
||||
Shows per-test results with redesigned
|
||||
layout for efficient comparison.
|
||||
|
||||
:CP debug
|
||||
Same as above but with the debug mode configured
|
||||
settings.
|
||||
View Commands ~
|
||||
:CP run [n] Run tests in I/O view (see |cp-io-view|).
|
||||
Lightweight split showing test verdicts.
|
||||
Without [n]: runs all tests, shows verdict summary
|
||||
With [n]: runs test n, shows detailed output
|
||||
Examples: >
|
||||
:CP run " All tests, verdict list
|
||||
:CP run 3 " Test 3 detail
|
||||
<
|
||||
:CP panel [n] Open full-screen test panel (see |cp-panel|).
|
||||
Aggregate table with diff modes for detailed analysis.
|
||||
Optional [n] focuses on specific test.
|
||||
Example: >
|
||||
:CP panel " All tests with diffs
|
||||
:CP panel 2 " Focus on test 2
|
||||
<
|
||||
:CP debug [n] Same as :CP panel but uses debug build configuration.
|
||||
|
||||
:CP pick Launch configured picker for interactive
|
||||
platform/contest selection.
|
||||
|
|
@ -145,8 +154,8 @@ Here's an example configuration with lazy.nvim:
|
|||
open_url = true,
|
||||
debug = false,
|
||||
ui = {
|
||||
panel = {
|
||||
ansi = true,
|
||||
panel = {
|
||||
diff_mode = 'vim',
|
||||
max_output_lines = 50,
|
||||
},
|
||||
|
|
@ -238,14 +247,14 @@ run CSES problems with Rust using the single schema:
|
|||
|
||||
*CpUI*
|
||||
Fields: ~
|
||||
{ansi} (boolean, default: true) Enable ANSI color parsing
|
||||
and highlighting in both I/O view and panel.
|
||||
{panel} (|PanelConfig|) Test panel behavior configuration.
|
||||
{diff} (|DiffConfig|) Diff backend configuration.
|
||||
{picker} (string|nil) 'telescope', 'fzf-lua', or nil.
|
||||
|
||||
*cp.PanelConfig*
|
||||
Fields: ~
|
||||
{ansi} (boolean, default: true) Enable ANSI color parsing
|
||||
and highlighting.
|
||||
{diff_mode} (string, default: "none") Diff backend: "none",
|
||||
"vim", or "git".
|
||||
{max_output_lines} (number, default: 50) Maximum lines of test output.
|
||||
|
|
@ -272,16 +281,32 @@ run CSES problems with Rust using the single schema:
|
|||
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 the state
|
||||
module documentation (lua/cp/state.lua) for available methods and fields.
|
||||
Hook functions receive the cp.nvim state object (|cp.State|). See
|
||||
|lua/cp/state.lua| for available methods and fields.
|
||||
|
||||
Example usage in hook:
|
||||
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:
|
||||
>lua
|
||||
hooks = {
|
||||
setup_code = function(state)
|
||||
print("Setting up " .. state.get_base_name())
|
||||
print("Source file: " .. state.get_source_file())
|
||||
end,
|
||||
setup_io_input = function(bufnr, state)
|
||||
-- Custom setup for input buffer
|
||||
vim.api.nvim_set_option_value('number', false, { buf = bufnr })
|
||||
end
|
||||
}
|
||||
<
|
||||
|
|
@ -333,8 +358,9 @@ Example: Setting up and solving AtCoder contest ABC324
|
|||
|
||||
3. Code your solution, then test: >
|
||||
:CP run
|
||||
< Navigate with j/k, run specific tests with <enter>
|
||||
Exit test panel with q or :CP run when done
|
||||
< View test verdicts in I/O splits. For detailed analysis:
|
||||
:CP panel
|
||||
< Navigate tests with <c-n>/<c-p>, exit with q
|
||||
|
||||
4. Move to next problem: >
|
||||
:CP next
|
||||
|
|
@ -349,6 +375,44 @@ Example: Setting up and solving AtCoder contest ABC324
|
|||
|
||||
7. Submit solutions on AtCoder website
|
||||
|
||||
==============================================================================
|
||||
I/O VIEW *cp-io-view*
|
||||
|
||||
The I/O view provides the main view aggregate view into test input and
|
||||
program output. Used time/memory per test case are appended to the output.
|
||||
The |cp-panel| offers more fine-grained analysis into each test case.
|
||||
|
||||
Access the I/O view with :CP run [n]
|
||||
|
||||
Layout ~
|
||||
|
||||
The I/O view appears as 30% width splits on the right side: >
|
||||
|
||||
┌──────────────────────────┬──────────────────────────┐
|
||||
│ │ Output │
|
||||
│ │ Test 1: AC (42ms, 8MB) │
|
||||
│ │ Test 2: AC (38ms, 8MB) │
|
||||
│ Solution Code │ Test 3: WA (45ms, 8MB) │
|
||||
│ │ Test 4: AC (51ms, 9MB) │
|
||||
│ ├──────────────────────────┤
|
||||
│ │ Input │
|
||||
│ │ 5 3 │
|
||||
│ │ 1 2 3 4 5 │
|
||||
│ │ 2 1 │
|
||||
│ │ 10 20 │
|
||||
└──────────────────────────┴──────────────────────────┘
|
||||
<
|
||||
Usage ~
|
||||
|
||||
:CP run Run all tests
|
||||
:CP run 3 Run test 3
|
||||
|
||||
Buffer Customization ~
|
||||
|
||||
Use the setup_io_input and setup_io_output hooks (see |cp.Hooks|) to customize
|
||||
buffer appearance. By default, line numbers and columns are removed via
|
||||
helpers.clearcol (see |cp-helpers|).
|
||||
|
||||
==============================================================================
|
||||
PICKER INTEGRATION *cp-picker*
|
||||
|
||||
|
|
@ -367,11 +431,13 @@ PICKER KEYMAPS *cp-picker-keys*
|
|||
Useful when contest lists are outdated or incomplete
|
||||
|
||||
==============================================================================
|
||||
PANEL *cp-run*
|
||||
PANEL *cp-panel*
|
||||
|
||||
The panel provides individual test case debugging. Problem time/memory
|
||||
limit constraints are in columns Time/Mem respectively. Used time/memory are
|
||||
in columns Runtime/RSS respectively.
|
||||
The panel provides full-screen test analysis with diff modes for detailed
|
||||
debugging. Problem time/memory limit constraints are in columns Time/Mem
|
||||
respectively. Used time/memory are in columns Runtime/RSS respectively.
|
||||
|
||||
Access with :CP panel or :CP debug (uses debug build configuration).
|
||||
|
||||
Interface ~
|
||||
|
||||
|
|
@ -502,12 +568,33 @@ Customize highlight groups after your colorscheme loads:
|
|||
})
|
||||
|
||||
==============================================================================
|
||||
PANEL KEYMAPS *cp-test-keys*
|
||||
HELPERS *cp-helpers*
|
||||
|
||||
The helpers module provides utility functions for buffer customization.
|
||||
Access via:
|
||||
>lua
|
||||
local helpers = require('cp').helpers
|
||||
<
|
||||
Functions ~
|
||||
|
||||
helpers.clearcol({bufnr}) *helpers.clearcol*
|
||||
Remove line numbers, columns, and signs from buffer.
|
||||
Sets:
|
||||
• number = false
|
||||
• relativenumber = false
|
||||
• signcolumn = 'no'
|
||||
• statuscolumn = ''
|
||||
|
||||
Parameters: ~
|
||||
{bufnr} (integer) Buffer handle
|
||||
|
||||
==============================================================================
|
||||
PANEL KEYMAPS *cp-panel-keys*
|
||||
|
||||
<c-n> Navigate to next test case
|
||||
<c-p> Navigate to previous test case
|
||||
t Cycle through diff modes: none → git → vim
|
||||
q Exit run panel and restore layout
|
||||
q Exit panel and restore layout
|
||||
<c-q> Exit interactive terminal and restore layout
|
||||
|
||||
Diff Modes ~
|
||||
|
|
@ -537,8 +624,7 @@ cp.nvim creates the following file structure upon problem setup: >
|
|||
{problem_id}.run " Compiled binary
|
||||
io/
|
||||
{problem_id}.n.cpin " nth test input
|
||||
{problem_id}.n.cpout " nth program output
|
||||
{problem_id}.expected " Expected output
|
||||
{problem_id}.n.cpout " nth test expected output
|
||||
<
|
||||
==============================================================================
|
||||
HEALTH CHECK *cp-health*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue