competitest

所属分类:collect
开发工具:Lua
文件大小:0KB
下载次数:0
上传日期:2023-07-19 08:15:06
上 传 者sh-1993
说明:  CompetiTest.nvim是一个Neovim插件,用于自动化测试用例管理和检查竞争编程,
(CompetiTest.nvim is a Neovim plugin to automate testcases management and checking for Competitive Programming,)

文件列表:
.stylua.toml (140, 2023-09-20)
COPYING (35149, 2023-09-20)
COPYING.LESSER (7652, 2023-09-20)
lua/ (0, 2023-09-20)
lua/competitest/ (0, 2023-09-20)
lua/competitest/commands.lua (12175, 2023-09-20)
lua/competitest/compare.lua (1640, 2023-09-20)
lua/competitest/config.lua (9544, 2023-09-20)
lua/competitest/init.lua (2706, 2023-09-20)
lua/competitest/receive.lua (8088, 2023-09-20)
lua/competitest/runner.lua (9961, 2023-09-20)
lua/competitest/runner_ui/ (0, 2023-09-20)
lua/competitest/runner_ui/init.lua (13546, 2023-09-20)
lua/competitest/runner_ui/popup.lua (4011, 2023-09-20)
lua/competitest/runner_ui/split.lua (4497, 2023-09-20)
lua/competitest/testcases.lua (11588, 2023-09-20)
lua/competitest/utils.lua (6359, 2023-09-20)
lua/competitest/widgets.lua (9267, 2023-09-20)

# CompetiTest.nvim
![Neovim](https://img.shields.io/badge/NeoVim-0.5+-%2357A143.svg?&style=for-the-badge&logo=neovim) ![Lua](https://img.shields.io/badge/Lua-%232C2D72.svg?style=for-the-badge&logo=lua) ![License](https://img.shields.io/github/license/xeluxee/competitest.nvim?style=for-the-badge&logo=gnu) ## Competitive Programming with Neovim made Easy ![competitest_popup_ui](https://user-images.githubusercontent.com/88047141/149839002-280069e5-0c71-4aec-8e39-4443a1c44f5c.png) *CompetiTest's popup UI* ![competitest_split_ui](https://user-images.githubusercontent.com/88047141/183751179-e07e2a4d-e2eb-468b-ba34-bb737cba4557.png) *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](#customize-compile-and-run-commands) - 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](#configuration)). You can even configure [every folder individually](#local-configuration) - Testcases can be stored in a single file or in multiple text files, see [usage notes](#usage-notes) - Easily [add](#add-or-edit-a-testcase), [edit](#add-or-edit-a-testcase) and [delete](#remove-a-testcase) testcases - [Run](#run-testcases) your program across all the testcases, showing results and execution data in a nice interactive UI - [Download](#receive-testcases-problems-and-contests) testcases, problems and contests automatically from competitive programming platforms - [Templates](#templates-for-received-problems-and-contests) for received problems and contests - View diff between actual and expected output - [Customizable interface](#customize-ui-layout) that resizes automatically when Neovim window is resized - Integration with [statusline and winbar](#statusline-and-winbar-integration) - Customizable [highlight groups](#highlights) ## Installation **NOTE:** this plugins requires Neovim ≥ 0.5 Install with `vim-plug`: ``` vim Plug 'MunifTanjim/nui.nvim' " it's a dependency Plug 'xeluxee/competitest.nvim' ``` Install with `packer.nvim`: ``` lua use { 'xeluxee/competitest.nvim', requires = 'MunifTanjim/nui.nvim', config = function() require('competitest').setup() end } ``` Install with `lazy.nvim`: ``` lua { '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`](https://github.com/MunifTanjim/nui.nvim), hence it should be installed as a dependency. ## Usage To load this plugin call `setup()`: ``` lua require('competitest').setup() -- to use default configuration ``` ``` lua require('competitest').setup { -- to customize settings -- put here configuration } ``` To see all the available settings see [configuration](#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](https://msgpack.org/) encoded file - You can choose how to store them with `testcases_use_single_file` boolean option in in [configuration](#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](#convert-testcases) #### 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](#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](#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](#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](#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 ``, ``, or ``. To save and close testcase editor press `` or `:wq`. Of course these keybindings can be customized: see `editor_ui` `normal_mode_mappings` and `editor_ui` `insert_mode_mappings` in [configuration](#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](https://msgpack.org/) 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](#configuration) `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 `` - Kill the process associated with a testcase by pressing `K` - Kill all the processes associated with testcases by pressing `` #### 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_ui` `mappings` in [configuration](#configuration) ### Receive testcases, problems and contests **NOTE:** to get this feature working you need to install [competitive-companion](https://github.com/jmerle/competitive-companion) extension in your browser. Thanks to its integration with [competitive-companion](https://github.com/jmerle/competitive-companion), CompetiTest can download contents from competitive programming platforms: - Download only testcases with `:CompetiTest receive testcases` - Download a problem with `:CompetiTest receive problem` (source file is automatically created along with testcases) - Download an entire contest with `:CompetiTest receive contest` (make sure to be on the homepage of the contest, not of a single problem) After launching one of these commands click on the green plus button in your browser to start downloading.\ For further customization see receive options in [configuration](#configuration). #### Customize folder structure By default CompetiTest stores received problems and contests in current working directory. You can change this behavior through the options `received_problems_path`, `received_contests_directory` and `received_contests_problems_path`. See [receive modifiers](#receive-modifiers) for further details.\ Here are some tips: - Fixed directory for received problems (not contests): ``` lua received_problems_path = "$(HOME)/Competitive Programming/$(JUDGE)/$(CONTEST)/$(PROBLEM).$(FEXT)" ``` - Fixed directory for received contests: ``` lua received_contests_directory = "$(HOME)/Competitive Programming/$(JUDGE)/$(CONTEST)" ``` - Put every problem of a contest in a different directory: ``` lua received_contests_problems_path = "$(PROBLEM)/main.$(FEXT)" ``` - Example of file naming for Java contests: ``` lua received_contests_problems_path = "$(PROBLEM)/$(JAVA_MAIN_CLASS).$(FEXT)" ``` - Simplified file names, it works with Java and any other language because the modifier `$(JAVA_TASK_CLASS)` is generated from problem name removing all non-alphabetic and non-numeric characters, including spaces and punctuation: ``` lua received_contests_problems_path = "$(JAVA_TASK_CLASS).$(FEXT)" ``` #### Templates for received problems and contests When downloading a problem or a contest, source code templates can be configured for different file types. See `template_file` option in [configuration](#configuration).\ [Receive modifiers](#receive-modifiers) can be used inside template files to insert details about received problems. To enable this feature set `evaluate_template_modifiers` to `true`. Template example for C++: ``` cpp // Problem: $(PROBLEM) // Contest: $(CONTEST) // Judge: $(JUDGE) // URL: $(URL) // Memory Limit: $(MEMLIM) // Time Limit: $(TIMELIM) // Start: $(DATE) #include using namespace std; int main() { cout << "This is a template file" << endl; cerr << "Problem name is $(PROBLEM)" << endl; return 0; } ``` ## Configuration ### Full configuration Here you can find CompetiTest default configuration ``` lua require('competitest').setup { local_config_file_name = ".competitest.lua", floating_border = "rounded", floating_border_highlight = "FloatBorder", picker_ui = { width = 0.2, height = 0.3, mappings = { focus_next = { "j", "", "" }, focus_prev = { "k", "", "" }, close = { "", "", "q", "Q" }, submit = { "" }, }, }, editor_ui = { popup_width = 0.4, popup_height = 0.6, show_nu = true, show_rnu = false, normal_mode_mappings = { switch_window = { "", "", "" }, save_and_close = "", cancel = { "q", "Q" }, }, insert_mode_mappings = { switch_window = { "", "", "" }, save_and_close = "", cancel = "", }, }, runner_ui = { interface = "popup", selector_show_nu = false, selector_show_rnu = false, show_nu = true, show_rnu = false, mappings = { run_again = "R", run_all_again = "", kill = "K", kill_all = "", view_input = { "i", "I" }, view_output = { "a", "A" }, view_stdout = { "o", "O" }, view_stderr = { "e", "E" }, toggle_diff = { "d", "D" }, close = { "q", "Q" }, }, viewer = { width = 0.5, height = 0.5, show_nu = true, show_rnu = false, close_mappings = { "q", "Q" }, }, }, popup_ui = { total_width = 0.8, total_height = 0.8, layout = { { 4, "tc" }, { 5, { { 1, "so" }, { 1, "si" } } }, { 5, { { 1, "eo" }, { 1, "se" } } }, }, }, split_ui = { position = "right", relative_to_editor = true, total_width = 0.3, vertical_layout = { { 1, "tc" }, { 1, { { 1, "so" }, { 1, "eo" } } }, { 1, { { 1, "si" }, { 1, "se" } } }, }, total_height = 0.4, horizontal_layout = { { 2, "tc" }, { 3, { { 1, "so" }, { 1, "si" } } }, { 3, { { 1, "eo" }, { 1, "se" } } }, }, }, save_current_file = true, save_all_files = false, compile_directory = ".", compile_command = { c = { exec = "gcc", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } }, cpp = { exec = "g++", args = { "-Wall", "$(FNAME)", "-o", "$(FNOEXT)" } }, rust = { exec = "rustc", args = { "$(FNAME)" } }, java = { exec = "javac", args = { "$(FNAME)" } }, }, running_directory = ".", run_command = { c = { exec = "./$(FNOEXT)" }, cpp = { exec = "./$(FNOEXT)" }, rust = { exec = "./$(FNOEXT)" }, python = { exec = "python", args = { "$(FNAME)" } }, java = { exec = "java", args = { "$(FNOEXT)" } }, }, multiple_testing = -1, maximum_time = 5000, output_compare_method = "squish", view_output_diff = false, testcases_directory = ".", testcases_use_single_file = false, testcases_auto_detect_storage = true, testcases_single_file_format = "$(FNOEXT).testcases", testcases_input_file_format = "$(FNOEXT)_input$(TCNUM).txt", testcases_output_file_format = "$(FNOEXT)_output$(TCNUM).txt", companion_port = 27121, receive_print_message = true, template_file = false, evaluate_template_modifiers = false, date_format = "%c", received_files_extension = "cpp", received_problems_path = "$(CWD)/$(PROBLEM).$(FEXT)", received_problems_prompt_path = true, received_contests_directory = "$(CWD)", received_contests_problems_path = "$(PROBLEM).$(FEXT)", received_contests_prompt_directory = true, received_contests_prompt_extension = true, open_received_problems = true, open_received_contests = true, replace_received_testcases = false, } ``` #### Explanation - `local_config_file_name`: you can use a different configuration for every different folder. See [local configuration](#local-configuration) - `floating_border`: for details see [here](https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup#borderstyle) - `floating_border_highlight`: the highlight group used for popups border - `picker_ui`: settings related to the testcase picker - `width`: a value from 0 to 1, representing the ratio between picker width and Neovim width - `height`: a value from 0 to 1, representing the ratio between picker height and Neovim height - `mappings`: keyboard mappings to interact with picker - `editor_ui`: settings related to the testcase editor - `popup_width`: a value from 0 to 1, representing the ratio between editor width and Neovim width - `popup_height`: a value from 0 to 1, representing the ratio between editor height and Neovim height - `show_nu`: whether to show line numbers or not - `show_rnu`: whether to show relative line numbers or not - `switch_window`: keyboard mappings to switch between input window and output window - `save_and_close`: keyboard mappings to save testcase content - `cancel`: keyboard mappings to quit testcase editor without saving - `runner_ui`: settings related to testcase runner user interface - `interface`: interface used to display testcases data. Can be `popup` (floating windows) or `split` (normal windows). Associated settings can be found in `popup_ui` and `split_ui` - `selector_show_nu`: whether to show line numbers or not in testcase selector - `selector_show_rnu`: whether to show relative line numbers or not in testcase selector - `show_nu`: whether to show line numbers or not in details windows - `show_rnu`: whether to show relative line numbers or not in details windows - `mappings`: keyboard mappings used in testcase selector window - `run_again`: keymaps to run again a testcase - `run_all_again`: keymaps to run again all testcases - `kill`: keymaps to kill a testcase - `kill_all`: keymaps to kill all testcases - `view_input`: keymaps to view input (stdin) in a bigger window - `view_output`: keymaps to view expected output in a bigger window - `view_stdout`: keymaps to view programs's output (stdout) in a bigger window - `view_stderr`: keymaps to view programs's errors (stderr) in a bigger window - `toggle_diff`: keymaps to toggle diff view between actual and expected output - `close`: keymaps to close runner user interface - `viewer`: keyboard mappings used in [viewer window](#view-details) - `width`: a value from 0 to 1, representing the ratio between viewer window width and Neovim width - `height`: a value from 0 to 1, representing the ratio between viewer window height and Neovim height - `show_nu`: whether to show line numbers or not in viewer window - `show_rnu`: whether to show relative line numbers or not in viewer window - `close_mappings`: keymaps to close viewer window - `popup_ui`: settings related to testcase runner popup interface - `total_width`: a value from 0 to 1, representing the ratio between total interface width and Neovim width - `total_height`: a value from 0 to 1, representing the ratio between total interface height and Neovim height - `layout`: a table describing popup UI layout. For further details see [here](#customize-ui-layout) - `split_ui`: settings related to testcase runner split interface - `position`: can be `top`, `bottom`, `left` or `right` - `relative_to_editor`: whether to open split UI relatively to entire editor or to local window - `total_width`: a value from 0 to 1, representing the ratio between total **vertical** split width and relative window width - `vertical_layout`: a table describing vertical split UI layout. For further details see [here](#customize-ui-layout) - `total_height`: a value from 0 to 1, representing the ratio between total **horizontal** split height and relative window height - `horizontal_layout`: a table describing horizontal split UI layout. For further details see [here](#customize-ui-layout) - `save_current_file`: if true save current file before running testcases - `save_all_files`: if true save all the opened files before running testcases - `compile_directory`: execution directory of compiler, relatively to current file's path - ` ... ...

近期下载者

相关文件


收藏者