feat(doc): update docs
This commit is contained in:
parent
c152e91819
commit
bdb0703986
1 changed files with 84 additions and 87 deletions
169
doc/cp.txt
169
doc/cp.txt
|
|
@ -1,23 +1,28 @@
|
||||||
*cp.txt* Competitive programming plugin for Neovim
|
*cp.txt* Competitive programming plugin for Neovim
|
||||||
|
|
||||||
Author: frozen <frozen@example.com>
|
Author: Barrett Ruth <br.barrettruth@gmail.com>
|
||||||
License: Same terms as Vim itself (see |license|)
|
License: Same terms as Vim itself (see |license|)
|
||||||
|
|
||||||
INTRODUCTION *cp* *cp.nvim*
|
INTRODUCTION *cp* *cp.nvim*
|
||||||
|
|
||||||
CP.nvim is a competitive programming plugin that automates problem setup,
|
cp.nvim is a competitive programming plugin that automates problem setup,
|
||||||
compilation, and testing workflow for online judges.
|
compilation, and testing workflow for online judges.
|
||||||
|
|
||||||
Supported platforms:
|
Supported platforms: AtCoder, Codeforces, CSES
|
||||||
- AtCoder
|
|
||||||
- Codeforces
|
|
||||||
- CSES
|
|
||||||
|
|
||||||
COMMANDS *cp-commands*
|
REQUIREMENTS *cp-requirements*
|
||||||
|
|
||||||
*:CP*
|
- Neovim 0.10.0+
|
||||||
|
- uv package manager (https://docs.astral.sh/uv/)
|
||||||
|
- C++ compiler (g++/clang++)
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
- LuaSnip for template expansion (https://github.com/L3MON4D3/LuaSnip)
|
||||||
|
|
||||||
|
COMMANDS *cp-commands*
|
||||||
|
|
||||||
|
*:CP*
|
||||||
:CP {contest} Set up contest environment for {contest}.
|
:CP {contest} Set up contest environment for {contest}.
|
||||||
Creates build/ and io/ directories.
|
|
||||||
Available contests: atcoder, codeforces, cses
|
Available contests: atcoder, codeforces, cses
|
||||||
|
|
||||||
:CP {contest} {problem} Set up problem from {contest}. Scrapes test
|
:CP {contest} {problem} Set up problem from {contest}. Scrapes test
|
||||||
|
|
@ -25,7 +30,7 @@ COMMANDS *cp-commands*
|
||||||
|
|
||||||
:CP {contest} {problem} {letter}
|
:CP {contest} {problem} {letter}
|
||||||
For AtCoder/Codeforces: set up problem with
|
For AtCoder/Codeforces: set up problem with
|
||||||
specific letter (a, b, c, etc.)
|
specific letter (e.g. a, b, c)
|
||||||
|
|
||||||
:CP {problem} Set up {problem} in current contest mode.
|
:CP {problem} Set up {problem} in current contest mode.
|
||||||
Requires contest to be set first.
|
Requires contest to be set first.
|
||||||
|
|
@ -39,53 +44,65 @@ COMMANDS *cp-commands*
|
||||||
:CP diff Enter diff mode to compare actual vs expected
|
:CP diff Enter diff mode to compare actual vs expected
|
||||||
output. Run again to exit diff mode.
|
output. Run again to exit diff mode.
|
||||||
|
|
||||||
CONFIGURATION *cp-config*
|
CONFIGURATION *cp-config*
|
||||||
|
|
||||||
Configure CP.nvim by calling setup() in your init.lua: >
|
cp.nvim is automatically lazy-loaded - no config/setup is required.
|
||||||
|
|
||||||
require('cp').setup({
|
Provide extra options via a setup() function with your package manager. For
|
||||||
contests = {
|
example, with lazy.nvim (https://github.com/folke/lazy.nvim):
|
||||||
atcoder = {
|
|
||||||
cpp_version = 23,
|
{
|
||||||
timeout_ms = 3000,
|
'barrett-ruth/cp.nvim',
|
||||||
},
|
config = function()
|
||||||
custom = {
|
local ls = require('luasnip')
|
||||||
cpp_version = 20,
|
local s = ls.snippet
|
||||||
compile_flags = {"-O2", "-DLOCAL"},
|
|
||||||
debug_flags = {"-g", "-fsanitize=address"},
|
require('cp').setup({
|
||||||
timeout_ms = 2000,
|
contests = {
|
||||||
},
|
default = {
|
||||||
},
|
cpp_version = 20,
|
||||||
snippets = {
|
compile_flags = { "-O2", "-DLOCAL", "-Wall", "-Wextra" },
|
||||||
-- LuaSnip snippets for contest types
|
debug_flags = { "-g3", "-fsanitize=address,undefined", "-DLOCAL" },
|
||||||
},
|
timeout_ms = 2000,
|
||||||
hooks = {
|
},
|
||||||
before_run = function(problem_id)
|
atcoder = {
|
||||||
-- Called before running problem
|
cpp_version = 23,
|
||||||
end,
|
},
|
||||||
before_debug = function(problem_id)
|
},
|
||||||
-- Called before debugging problem
|
snippets = {
|
||||||
end,
|
cses = {
|
||||||
},
|
s("cses", "#include <iostream>\nusing namespace std;\n\nint main() {\n\t$0\n}")
|
||||||
})
|
},
|
||||||
|
},
|
||||||
|
hooks = {
|
||||||
|
before_run = function(problem_id)
|
||||||
|
vim.cmd.w()
|
||||||
|
vim.lsp.buf.format()
|
||||||
|
end,
|
||||||
|
before_debug = function(problem_id)
|
||||||
|
...
|
||||||
|
end
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
Configuration options:
|
Configuration options:
|
||||||
|
|
||||||
contests Dictionary of contest configurations.
|
contests Dictionary of contest configurations - each contest inherits from 'default'.
|
||||||
Each contest inherits from 'default'.
|
|
||||||
|
|
||||||
cpp_version C++ standard version (17, 20, 23, etc.)
|
cpp_version c++ standard version (e.g. 20, 23)
|
||||||
compile_flags List of compiler flags for release builds
|
compile_flags compiler flags for run builds
|
||||||
debug_flags List of compiler flags for debug builds
|
debug_flags compiler flags for debug builds
|
||||||
timeout_ms Execution timeout in milliseconds
|
timeout_ms duration (ms) to run/debug before timeout
|
||||||
|
|
||||||
snippets Custom LuaSnip snippets by contest type
|
snippets LuaSnip snippets by contest type
|
||||||
|
|
||||||
hooks Functions called at specific events
|
hooks Functions called at specific events
|
||||||
before_run Called before :CP run
|
before_run Called before :CP run
|
||||||
before_debug Called before :CP debug
|
before_debug Called before :CP debug
|
||||||
|
|
||||||
WORKFLOW *cp-workflow*
|
WORKFLOW *cp-workflow*
|
||||||
|
|
||||||
1. Set up contest environment: >
|
1. Set up contest environment: >
|
||||||
:CP atcoder
|
:CP atcoder
|
||||||
|
|
@ -94,66 +111,46 @@ WORKFLOW *cp-workflow*
|
||||||
:CP abc123 a
|
:CP abc123 a
|
||||||
<
|
<
|
||||||
This creates abc123a.cc and scrapes test cases to io/abc123a.in and
|
This creates abc123a.cc and scrapes test cases to io/abc123a.in and
|
||||||
io/abc123a.expected
|
io/abc123a.expected. Alternatively, run :CP atcoder abc123 a
|
||||||
|
|
||||||
3. Write solution in abc123a.cc
|
3. Write, test, and view your solution output:
|
||||||
|
|
||||||
4. Test solution: >
|
|
||||||
:CP run
|
:CP run
|
||||||
<
|
<
|
||||||
Output appears in vertical split showing execution time, output, and
|
Output appears in vertical split showing execution time, output, and
|
||||||
whether it matches expected output.
|
whether it matches expected output.
|
||||||
|
|
||||||
5. Debug if needed: >
|
4. Debug if needed:
|
||||||
|
|
||||||
:CP debug
|
:CP debug
|
||||||
<
|
<
|
||||||
6. Compare outputs visually: >
|
5. Compare actual vs. expected output visually: >
|
||||||
|
|
||||||
:CP diff
|
:CP diff
|
||||||
<
|
<
|
||||||
Enters 3-way diff mode with actual, expected, and input files.
|
Enters 3-way diff mode with actual, expected, and input files.
|
||||||
|
|
||||||
FILE STRUCTURE *cp-files*
|
FILE STRUCTURE *cp-files*
|
||||||
|
|
||||||
After setting up a problem, your directory structure looks like: >
|
cp.nvim creates the following file structure upon setup:
|
||||||
|
|
||||||
problem.cc # Source file
|
problem.cc
|
||||||
build/ # Compiled executables
|
build/*.{run,debug}
|
||||||
io/
|
io/
|
||||||
problem.in # Test input
|
problem.in
|
||||||
problem.out # Actual output
|
problem.out
|
||||||
problem.expected # Expected output
|
problem.expected
|
||||||
|
|
||||||
The plugin manages all files automatically. You only need to edit the
|
SNIPPETS *cp-snippets*
|
||||||
source file.
|
|
||||||
|
|
||||||
HEALTH CHECK *cp-health*
|
cp.nvim integrates with LuaSnip for automatic template expansion. When you
|
||||||
|
open a new problem file, type the contest name and press <Tab> to expand.
|
||||||
|
|
||||||
Run |:checkhealth| cp to verify your setup:
|
Built-in snippets include basic C++ templates for each contest type.
|
||||||
- Neovim version compatibility
|
Custom snippets can be added via configuration.
|
||||||
- uv package manager availability
|
|
||||||
- Python virtual environment status
|
|
||||||
- Problem scrapers presence
|
|
||||||
- LuaSnip integration
|
|
||||||
- Directory structure
|
|
||||||
|
|
||||||
TROUBLESHOOTING *cp-troubleshooting*
|
HEALTH CHECK *cp-health*
|
||||||
|
|
||||||
Problem scraping fails ~
|
Run |:checkhealth| cp to verify your setup.
|
||||||
- Ensure uv is installed: https://docs.astral.sh/uv/
|
|
||||||
- Check internet connectivity
|
|
||||||
- Verify contest and problem IDs are correct
|
|
||||||
- Run |:checkhealth| cp for detailed diagnostics
|
|
||||||
|
|
||||||
Compilation errors ~
|
|
||||||
- Check C++ version compatibility with contest requirements
|
|
||||||
- Verify compiler flags in configuration
|
|
||||||
- Ensure source file syntax is correct
|
|
||||||
|
|
||||||
Template expansion not working ~
|
|
||||||
- Install LuaSnip plugin for automatic snippet expansion
|
|
||||||
- Check snippets configuration
|
|
||||||
- Ensure file is empty when opening new problem
|
|
||||||
|
|
||||||
For more help, report issues at: https://github.com/frozen/cp.nvim
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue