SkillAgentSearch skills...

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.nvim
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

CompetiTest.nvim

<div align="center">

Neovim Lua License

Competitive Programming with Neovim made Easy

<!-- ![competitest_old](https://user-images.githubusercontent.com/88047141/147982101-2576e960-372c-4dec-b65e-97191c23a57d.png) -->

competitest_popup_ui CompetiTest's popup UI

competitest_split_ui CompetiTest's split UI

</div>

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 stdin and print to stdout. If stderr is 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_file boolean 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_storage is true
    • If you want to change the way already existing testcases are stored see conversion

Storing testcases in multiple text files

  • To store testcases in multiple text files set testcases_use_single_file to 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 named task-A_input0.txt, task-A_output0.txt, task-A_input1.txt, task-A_output1.txt and so on. The counting starts from 0
  • Of course files naming can be configured: see testcases_input_file_format and testcases_output_file_format in configuration
  • Testcases files can be put in the same folder of the source code file, but you can customize their path (see testcases_directory in configuration)

Storing testcases in a single file

  • To store testcases in a single file set testcases_use_single_file to 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 named task-A.testcases
  • Of course single file naming can be configured: see testcases_single_file_format in configuration
  • Testcases file can be put in the same folder of the source code file, but you can customize its path (see testcases_directory in 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_uinormal_mode_mappings and editor_uiinsert_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 files
  • files_to_singlefile: convert multiple text files into a single file
  • auto: 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 i or I
  • View expected output in a bigger window by pressing a or A
  • View stdout in a bigger window by pressing o or O
  • View stderr in a bigger window by pressing e or E
  • Toggle diff view between actual and expected output by pressing d or D

Of course all these keybindings can be customized: see runner_uimappings 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 testcases to only receive testcases once
  • Launch :CompetiTest receive problem to receive a problem once (source file is automatically created along with testcases)
  • Launch :CompetiTest receive contest to receive an entire contest once (make sure to be on the homepage of the contest, not of a single problem)
  • Launch :CompetiTest receive persistently to keep receiving testcases, problems and contests persistently (also see the option start_receiving_persistently_on_setup)
  • Launch :CompetiTest receive status to show current receive status
  • Launch :CompetiTest receive stop to stop receiving

After launching one of these commands click on the green plus button i

Related Skills

View on GitHub
GitHub Stars570
CategoryDevelopment
Updated11d ago
Forks30

Languages

Lua

Security Score

100/100

Audited on Mar 18, 2026

No findings