One important factor in competitive programming is Speed, make sure you don't compromise with that, while using some fancy plugin or software.
-- Example to setup for C++ and Python
{
"A7lavinraj/assistant.nvim",
dependencies = { "stevearc/dressing.nvim" }, -- optional but recommended
opts = { -- you can also pass opts as {}, cpp and python are supported by default
commands = {
python = {
extension = "py",
compile = nil,
execute = {
main = "python3",
args = { "$FILENAME_WITH_EXTENSION" }
},
},
cpp = {
extension = "cpp",
compile = {
main = "g++",
args = { "$FILENAME_WITH_EXTENSION", "-o", "$FILENAME_WITHOUT_EXTENSION" }
},
execute = {
main = "./$FILENAME_WITHOUT_EXTENSION",
args = nil
},
},
},
time_limit = 5000,
border = false, -- border is OFF by default, you can can pass true to enable borders
theme = "dynamic" -- "gruvbox", "catppuccin" and "tokyonight" are also available
}
}
g++ example.cpp -o example # {main} {arg1} {args2} {arg3}
Above code snippet is a command to compile a C++ file, If you take a closure look on the comment right infront of command you can guess main = g++
, arg1 = example.cpp
, arg2 = -o
and arg3 = example
, So if i want to extend the configuration for Python
, I just need to add following code snippet to commands table.
python = {
extension = "py", -- your prefered file extension for python file
compile = nil, -- since python code doesn't get compiled so pass a nil
execute = { -- {main} command and array of {args} as we saw earlier.
main = "python3",
args = { "$FILENAME_WITH_EXTENSION" }
},
},
key to the new table is type of file you want to run. In this case is
python
, you can get the correct filetype of file by just open that file inside neovim and type the following command.
:lua print(vim.bo.filetype)
time_limit
option is used to limit your code execution process to prevent infinite execution.border
option is used to enable borders.theme
option is used to change themes. there are only four options yet gruvbox
, catppuccin
, tokyonight
and dynamic
. dynamic
option uses the current environment colorsheme.https://github.com/user-attachments/assets/cf62cd9e-8b23-48be-86f5-c5ae24915b63
In the above video guide you can see every feature that this plugin provides.
There is only one command to interact with plugin AssistantToggle which toggle the UI window of plugin and rest operations are done by keymappings.
-- command to open and close plugin window
:AssistantToggle
-- prefered keymap for conciseness
vim.keymap.set("n", "<leader>a", "<cmd>AssistantToggle<cr>", { desc = "Assistant window toggle" })
Key | Operation |
---|---|
Tab |
Move between splits |
Esc |
Close current window |
q |
Close current window |
r |
Run testcase on which the cursor is holded |
R |
Run all available testcases |
c |
Create an empty testcase |
d |
Delete testcase on which the cursor is holded |
i |
Open prompt window for updating input |
e |
Open prompt window for updating expected output |
n |
Move to next available testcase |
p |
Move to previous available testcase |