A modern, extensible code execution plugin for Neovim supporting 30+ languages with multiple execution strategies.
- 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
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" },
},
}
Using packer.nvim
use {
"bhushan/coderunner.nvim",
requires = { "folke/snacks.nvim" }, -- Optional
config = function()
require("coderunner").setup()
end
}
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",
},
},
})
<leader>x
- Run current file<leader>X
- Run with custom command<leader>xl
- List supported languages
:CodeRun
- Execute current file:CodeRunCustom
- Execute with custom command input:CodeRunList
- Show all 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... |
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()
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
- Neovim >= 0.9.0
- Language-specific compilers/interpreters installed
- Optional: Snacks.nvim for enhanced terminal experience
MIT