A plugin for automating tasks in competitive programming like downloading test cases, compiling and testing. Supports Rust, C, C++, Python and Lua.
- Neovim >= 0.4 (Current stable is 0.5)
- competitive-companion browser extension (works with Firefox and all Chromium browsers)
- Plugin:
nvim-lua/plenary.nvim
(Install using your plugin manager)
- Use
:CphReceive
and press the "parse task" button in the extension to prepare files. This will open an empty solution file in your preferred language. (See ) :CphTest [numbers]
to test your solution. If test case number(s) is specified, only those are run, otherwise, all cases are run.:CphRetest [numbers]
to test the same binary without recompiling.:CphEdit [number]
to edit/add a testcase.:CphDelete [numbers]
to delete testcases.
The filetype of the floating window showing results is Results
, so you can disable your indentline/cursorline plugins for this filetype.
demo.mp4
g:cphdir
: The directory in which contests are stored (default~/contests
) (Specify absolute path)g:cphlang
: Preferred language for the first solution file opened. You can open anothersolution.language
file for a particular problem using:e
and that file will be used.g:cphborder
: Border type used for the results window. Possible values: see:help nvim_open_win()
(default"rounded"
)g:rust_compile_command
: Command for compiling Rust files (defaultrustc solution.rs -o rust.out
)g:c_compile_command
: Command for compiling C files (defaultgcc solution.c -o c.out
). The input file must besolution.c
and the output file must bec.out
, this pref is only for compile flags.g:cpp_compile_command
: Command for compiling C++ files. See above. (defaultg++ solution.cpp -o cpp.out
)g:cphtimeout
: Time limit per test case in milliseconds (default 2000).g:cph_rust_createjson
: Whether to create arust-project.json
for rust-analyzer. (default false)g:cph_rustjson
:rust-project.json
created for rust-analyzer (see above).You likely need to change this to the appropriate value for your setup if it doesn't work, mostly change<home-directory>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu
to the output ofrustc --print sysroot
. Default:
{
"sysroot_src": "<home-directory>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/",
"crates": [
{
"root_module": "solution.rs",
"edition": "2018", // BE SURE TO CHECK THE EDITION WITH THE ONLINE JUDGE, THEIR VERSION MIGHT BE OLD.
"deps": []
}
]
}
Contests directory (g:cphdir)
├── Judge 1
│ ├── Contest 1
│ │ ├── Problem 1
│ │ │ ├── input1
│ │ │ ├── input2
│ │ │ ├── output1
│ │ │ ├── output2
│ │ │ ├── solution.c
│ │ │ ├── solution.cpp
│ │ │ └── solution.py
│ │ └── Problem 2
│ │ ├── input1
│ │ ├── output1
│ │ ├── solution.c
│ │ ├── solution.cpp
│ │ └── solution.py
│ └── Contest 2
│ └── Problem 1
│ ├── input1
│ ├── output1
│ ├── solution.c
│ ├── solution.cpp
│ └── solution.py
└── Judge 2
└── Contest 2
└── Problem 1
├── input1
├── output1
├── solution.c
├── solution.cpp
└── solution.py