Competitest.nvim
CompetiTest.nvim is a Neovim plugin for Competitive Programming: it can manage and check testcases, download problems and contests from online judges and much more
Install / Use
/learn @xeluxee/Competitest.nvimREADME
CompetiTest.nvim
<div align="center">
Competitive Programming with Neovim made Easy
<!--  -->
CompetiTest's popup UI
CompetiTest's split UI
competitest.nvim is a testcase manager and checker. It saves you time in competitive programming contests by automating common tasks related to testcase management. It can compile, run and test your solutions across all the available testcases, displaying results in a nice interactive user interface.
Features
- Multiple languages supported: it works out of the box with C, C++, Rust, Java and Python, but other languages can be configured
- Flexible. No strict file-naming rules, optional fixed folder structure. You can choose where to put the source code file, the testcases, the received problems and contests, where to execute your programs and much more
- Configurable (see Configuration). You can even configure every folder individually
- Testcases can be stored in a single file or in multiple text files, see usage notes
- Easily add, edit and delete testcases
- Run your program across all the testcases, showing results and execution data in a nice interactive UI
- Download testcases, problems and contests automatically from competitive programming platforms
- Templates for received problems and contests
- View diff between actual and expected output
- Customizable interface that resizes automatically when Neovim window is resized
- Integration with statusline and winbar
- Customizable highlight groups
Installation
NOTE: this plugins requires Neovim ≥ 0.5
Install with vim-plug:
Plug 'MunifTanjim/nui.nvim' " it's a dependency
Plug 'xeluxee/competitest.nvim'
Install with packer.nvim:
use {
'xeluxee/competitest.nvim',
requires = 'MunifTanjim/nui.nvim',
config = function() require('competitest').setup() end
}
Install with lazy.nvim:
{
'xeluxee/competitest.nvim',
dependencies = 'MunifTanjim/nui.nvim',
config = function() require('competitest').setup() end,
}
If you are using another package manager note that this plugin depends on nui.nvim, hence it should be installed as a dependency.
Usage
To load this plugin call setup():
require('competitest').setup() -- to use default configuration
require('competitest').setup { -- to customize settings
-- put here configuration
}
To see all the available settings see configuration.
Usage notes
- Your programs must read from
stdinand print tostdout. Ifstderris used its content will be displayed - A testcase is made by an input and an output (containing the correct answer)
- Input is necessary for a testcase to be considered, while an output hasn't to be provided necessarily
- Testcases can be stored in multiple text files or in a single msgpack encoded file
- You can choose how to store them with
testcases_use_single_fileboolean option in in configuration. By default it's false, so multiple files are used - Storage method can be automatically detected when option
testcases_auto_detect_storageis true - If you want to change the way already existing testcases are stored see conversion
- You can choose how to store them with
Storing testcases in multiple text files
- To store testcases in multiple text files set
testcases_use_single_fileto false - Files naming shall follow a rule to be recognized. Let's say your file is called
task-A.cpp. If using the default configuration testcases associated with that file will be namedtask-A_input0.txt,task-A_output0.txt,task-A_input1.txt,task-A_output1.txtand so on. The counting starts from 0 - Of course files naming can be configured: see
testcases_input_file_formatandtestcases_output_file_formatin configuration - Testcases files can be put in the same folder of the source code file, but you can customize their path (see
testcases_directoryin configuration)
Storing testcases in a single file
- To store testcases in a single file set
testcases_use_single_fileto true - Testcases file naming shall follow a rule to be recognized. Let's say your file is called
task-A.cpp. If using the default configuration testcases file will be namedtask-A.testcases - Of course single file naming can be configured: see
testcases_single_file_formatin configuration - Testcases file can be put in the same folder of the source code file, but you can customize its path (see
testcases_directoryin configuration)
Anyway you can forget about these rules if you use :CompetiTest add_testcase and :CompetiTest edit_testcase, that handle these things for you.
When launching the following commands make sure the focused buffer is the one containing the source code file.
Add or Edit a testcase
Launch :CompetiTest add_testcase to add a new testcase.
Launch :CompetiTest edit_testcase to edit an existing testcase. If you want to specify testcase number directly in the command line you can use :CompetiTest edit_testcase x, where x is a number representing the testcase you want to edit.
To jump between input and output windows press either <C-h>, <C-l>, or <C-i>. To save and close testcase editor press <C-s> or :wq.
Of course these keybindings can be customized: see editor_ui ➤ normal_mode_mappings and editor_ui ➤ insert_mode_mappings in configuration
Remove a testcase
Launch :CompetiTest delete_testcase. If you want to specify testcase number directly in the command line you can use :CompetiTest delete_testcase x, where x is a number representing the testcase you want to remove.
Convert testcases
Testcases can be stored in multiple text files or in a single msgpack encoded file.
Launch :CompetiTest convert to change testcases storage method: you can convert a single file into multiple files or vice versa.
One of the following arguments is needed:
singlefile_to_files: convert a single file into multiple text filesfiles_to_singlefile: convert multiple text files into a single fileauto: if there's a single file convert it into multiple files, otherwise convert multiple files into a single file
NOTE: this command only converts already existing testcases files without changing CompetiTest configuration. To choose the storage method to use you have to configure testcases_use_single_file option, that is false by default. Anyway storage method can be automatically detected when option testcases_auto_detect_storage is true.
Run testcases
Launch :CompetiTest run. CompetiTest's interface will appear and you'll be able to view details about a testcase by moving the cursor over its entry. You can close the UI by pressing q, Q or :q.
If you're using a compiled language and you don't want to recompile your program launch :CompetiTest run_no_compile.
If you have previously closed the UI and you want to re-open it without re-executing testcases or recompiling launch :CompetiTest show_ui.
Control processes
- Run again a testcase by pressing
R - Run again all testcases by pressing
<C-r> - Kill the process associated with a testcase by pressing
K - Kill all the processes associated with testcases by pressing
<C-k>
View details
- View input in a bigger window by pressing
iorI - View expected output in a bigger window by pressing
aorA - View stdout in a bigger window by pressing
oorO - View stderr in a bigger window by pressing
eorE - Toggle diff view between actual and expected output by pressing
dorD
Of course all these keybindings can be customized: see runner_ui ➤ mappings in configuration
Receive testcases, problems and contests
NOTE: to get this feature working you need to install competitive-companion extension in your browser.
Thanks to its integration with competitive-companion, CompetiTest can download contents from competitive programming platforms:
- Launch
:CompetiTest receive testcasesto only receive testcases once - Launch
:CompetiTest receive problemto receive a problem once (source file is automatically created along with testcases) - Launch
:CompetiTest receive contestto receive an entire contest once (make sure to be on the homepage of the contest, not of a single problem) - Launch
:CompetiTest receive persistentlyto keep receiving testcases, problems and contests persistently (also see the optionstart_receiving_persistently_on_setup) - Launch
:CompetiTest receive statusto show current receive status - Launch
:CompetiTest receive stopto stop receiving
After launching one of these commands click on the green plus button i
Related Skills
node-connect
340.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.1kCommit, push, and open a PR
