Skip to content

AdventOfVim/coderunner.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

CodeRunner.nvim

A modern, extensible code execution plugin for Neovim supporting 30+ languages with multiple execution strategies.

Features

  • 30+ Languages: JavaScript, Python, PHP, Go, Rust, C/C++, Java, and more
  • Smart Execution: Auto-detects optimal execution strategy per language
  • Optional Snacks.nvim: Falls back to native floating terminal
  • Modular Architecture: Easy to extend and customize
  • Custom Commands: Run with user-defined commands

Installation

Using lazy.nvim

{
  "bhushan/coderunner.nvim",
  dependencies = {
    "folke/snacks.nvim", -- Optional
  },
  config = function()
    require("coderunner").setup({
      -- Configuration options
    })
  end,
  keys = {
    { "<leader>x", "<cmd>CodeRun<cr>", desc = "Run Code" },
    { "<leader>X", "<cmd>CodeRunCustom<cr>", desc = "Run Code (Custom)" },
    { "<leader>xl", "<cmd>CodeRunList<cr>", desc = "List Languages" },
  },
}
use {
  "bhushan/coderunner.nvim",
  requires = { "folke/snacks.nvim" }, -- Optional
  config = function()
    require("coderunner").setup()
  end
}

Configuration

require("coderunner").setup({
  -- Use Snacks.nvim if available
  use_snacks = true,

  -- Terminal window configuration
  window = {
    width = 0.8,
    height = 0.8,
    border = "rounded",
  },

  -- Auto-save before execution
  auto_save = true,

  -- Custom language configurations
  languages = {
    -- Override or add new languages
    python = {
      cmd = "python3 %",
      description = "Python execution",
    },
  },
})

Usage

Default Keybindings

  • <leader>x - Run current file
  • <leader>X - Run with custom command
  • <leader>xl - List supported languages

Commands

  • :CodeRun - Execute current file
  • :CodeRunCustom - Execute with custom command input
  • :CodeRunList - Show all supported languages

Supported Languages

Language Execution Icon
JavaScript Terminal 󰆧
TypeScript Terminal 󰛦
Python Terminal 󰌠
PHP Terminal
Go Terminal 󰟓
Rust Terminal 󱘗
C/C++ Build+Run
Java Build+Run
Lua Inline 󰢱
And 20+ more...

API

local coderunner = require("coderunner")

-- Run current buffer
coderunner.run_code()

-- Run with custom command
coderunner.run_code_with_input()

-- Add language support
coderunner.add_language("mylang", {
  cmd = "mylang %",
  strategy = "terminal",
  description = "My Language execution",
})

-- Get supported languages
local langs = coderunner.get_supported_languages()

Architecture

coderunner.nvim/
├── lua/
│   └── coderunner/
│       ├── init.lua          # Main entry point
│       ├── config.lua         # Configuration management
│       ├── languages.lua      # Language definitions
│       ├── executor.lua       # Execution logic
│       ├── ui.lua             # UI components
│       └── terminal.lua       # Terminal abstraction
├── plugin/
│   └── coderunner.vim         # Vim commands
└── README.md

Requirements

  • Neovim >= 0.9.0
  • Language-specific compilers/interpreters installed
  • Optional: Snacks.nvim for enhanced terminal experience

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 94.2%
  • Vim Script 5.8%