Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

🚀 code-runner.nvim

A fast, flexible code runner for Neovim. Run code in 20+ languages with a single keypress, or define project-specific commands via coderun.json.

test.mp4

✨ Features

  • 20+ languages supported out of the box
  • Project-specific commands via coderun.json
  • Security-first: prompts before executing untrusted configs
  • Multiple terminal backends: sky-term, toggleterm, or built-in
  • File watching: auto-reloads when coderun.json changes
  • Custom keybinds per project

📦 Installation

lazy.nvim (recommended)

return {
{
"blurskye/code-runner.nvim",
dependencies= {
"MunifTanjim/nui.nvim", -- optional, for better config prompts
},
config=function()
require("code-runner").setup({
keymap="<F5>",
interrupt_keymap="<F2>",
-- debug = true,commands= {
-- Override or add commands herepython='python3 -u "$dir/$fileName"',
},
extensions= {
-- Override or add extensions herepython= { "py" },
},
})
end,
},
-- Terminal plugin (pick one)
{
"blurskye/skyTerm",
config=function()
require("sky-term").setup({
toggle_key="<C-\\>",
})
end,
},
}

Terminal Backends

The plugin tries terminals in this order:

  1. sky-term (recommended) - blurskye/skyTerm
  2. toggleterm - akinsho/toggleterm.nvim
  3. built-in - Neovim's :terminal

⚙️ Configuration

require("code-runner").setup({
keymap="<F5>", -- Run codeinterrupt_keymap="<F2>", -- Stop executiondebug=false, -- Enable debug logging-- Override or add language commandscommands= {
python='python3 -u "$dir/$fileName"',
javascript='node "$dir/$fileName"',
-- Add your own...
},
-- Map file extensions to languagesextensions= {
python= { "py", "pyw" },
javascript= { "js", "mjs" },
-- Add your own...
},
})

Supported Languages

Python, JavaScript, TypeScript, Lua, Ruby, Go, C, C++, Java, Bash, Rust, PHP, Perl, Zig, Kotlin, Swift, R, Julia, Elixir, Haskell, Scala, Dart

📁 Project Configuration

Create a coderun.json in your project root for custom commands:

{
"run": {
"command": "npm run dev",
"keybind": "<F5>"
},
"test": {
"command": "npm test",
"keybind": "<F6>"
},
"build": {
"command": "npm run build",
"keybind": "<F7>"
}
}

Variables

VariableDescription
$filePathFull path to current file
$fileNameCurrent file name with extension
$fileNameWithoutExtCurrent file name without extension
$fileExtensionCurrent file extension
$dirDirectory of current file
$coderunDirDirectory containing coderun.json

🔧 Commands

CommandDescription
:CodeRunnerRunRun current file
:CodeRunnerInterruptStop running code
:CodeRunnerReloadReload configuration
:CodeRunnerDebugToggle debug mode

🔒 Security

When a coderun.json is detected, you'll be prompted to review and accept it before any commands are executed. The plugin remembers your choice (per file hash) until the config changes.

📄 License

MIT

🤝 Contributing

Issues and PRs welcome!

About

code runner for neovim

Resources

Stars

20 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages