A minimal, fast Neovim plugin for competitive programming in C++.
Compile, run, and check output — nothing else.
- Split layout (
<leader>cp) — togglesinp/outside-by-side panes relative to active.cppdirectory. Auto-creates files if missing. - Auto-save —
inpandoutsave automatically as you edit them. - Quickfix error handling — compilation errors open in quickfix without blocking prompts or scrolling traps.
- Fast run (
<F6>) — compiles withg++ -O2, opens an interactive terminal. - Warnings build (
<F8>) — compiles with-Wall -Wextra -Wshadow -O2, runs silently viainp→out. - AddressSanitizer build (
<F7>) — compiles with-fsanitize=address, catches memory bugs. - Clean timing — shows run time as
✓ Finished in 42msor✗ Finished in 1.85s (exit code 1).
lazy.nvim:
{
"3p5ilon/cprun.nvim",
ft = "cpp",
opts = {},
}packer.nvim:
use({
"3p5ilon/cprun.nvim",
ft = "cpp",
config = function()
require("cprun").setup({})
end,
})require("cprun").setup({
compiler = "g++",
asan_compiler = "clang++",
cpp_std = "c++17",
flags = { "-Wall", "-Wextra", "-Wshadow", "-O2" },
fast_flags = { "-O2" },
asan_flags = { "-Wall", "-Wextra", "-Wshadow", "-fsanitize=address", "-O2" },
term_height = 10,
qf_height = 10,
layout_width = 0.35,
input_file = "inp",
output_file = "out",
auto_create_files = true,
auto_save = true,
keymaps = {
enable = true,
toggle_layout = "<leader>cp",
run_fast = "<F6>",
run_asan = "<F7>",
run_warnings = "<F8>",
},
})| Key | Command | What it does |
|---|---|---|
<leader>cp |
:CPToggle |
Toggle inp/out layout |
<F6> |
:CPRunFast |
Fast compile + interactive terminal |
<F7> |
:CPRunAsan |
Compile with ASan, run via inp → out |
<F8> |
:CPRunWarnings |
Compile with warnings, run via inp → out |
Any keymap can be remapped or set to false.
cprun.nvim doesn't include snippets. You can use LuaSnip for that — drop this in ~/.config/nvim/lua/snippets/cpp.lua and require("snippets.cpp") from your init.lua:
local ls = require("luasnip")
local s, t, i = ls.snippet, ls.text_node, ls.insert_node
ls.add_snippets("cpp", {
s("tem", {
t({
"#include <bits/stdc++.h>",
"using namespace std;",
"",
"int main() {",
" ios_base::sync_with_stdio(false);",
" cin.tie(NULL);",
"",
" ",
}),
i(1),
t({ "", " return 0;", "}", "" }),
}),
})See the LuaSnip docs for more.
This plugin intentionally does not include: multiple testcase management, verdict checking, online-judge integration, or snippets. For any of those, check out competitest.nvim — a much more feature-complete tool. cprun.nvim exists for people who just want the fast compile-run loop and nothing more.