Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cprun.nvim

A minimal, fast Neovim plugin for competitive programming in C++.

Compile, run, and check output — nothing else.

cprun demo img

Features

  • Split layout (<leader>cp) — toggles inp/out side-by-side panes relative to active .cpp directory. Auto-creates files if missing.
  • Auto-save — inp and out save automatically as you edit them.
  • Quickfix error handling — compilation errors open in quickfix without blocking prompts or scrolling traps.
  • Fast run (<F6>) — compiles with g++ -O2, opens an interactive terminal.
  • Warnings build (<F8>) — compiles with -Wall -Wextra -Wshadow -O2, runs silently via inp → out.
  • AddressSanitizer build (<F7>) — compiles with -fsanitize=address, catches memory bugs.
  • Clean timing — shows run time as ✓ Finished in 42ms or ✗ Finished in 1.85s (exit code 1).

Install

lazy.nvim:

{
  "3p5ilon/cprun.nvim",
  ft = "cpp",
  opts = {},
}

packer.nvim:

use({
  "3p5ilon/cprun.nvim",
  ft = "cpp",
  config = function()
    require("cprun").setup({})
  end,
})

Configuration

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>",
  },
})

Keymaps

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.

Snippets (optional, not bundled)

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.

Philosophy

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.

License

MIT

About

Minimal, fast C++ CP workflow plugin for Neovim

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages