Skip to content

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

nvim-live-runner πŸš€

Neovim Go Version License: MIT

A simple, real-time code runner for Neovim that provides instant feedback as you write code. Type in your Neovim buffer and see execution results update live in a split output window!


⚑ Quick Navigation

πŸš€ Quick Start πŸ“¦ Installation βš™οΈ Configuration πŸ› Troubleshooting

πŸ“š Table of Contents


✨ Features

  • ⚑ Instant Live Feedback: See code execution output update dynamically as you type (TextChanged and TextChangedI).
  • πŸš€ High Performance Backend: Powered by a lightweight Go TCP server for minimal CPU usage and fast execution.
  • πŸ”„ Dynamic Language Detection: Seamlessly switch between Python, Go, Lua, and JavaScript buffers without restarting the backend process.
  • ⏱️ Smart Debouncing: Built-in 250ms debouncer prevents CPU thrashing during rapid keystrokes.
  • πŸ›‘οΈ Process Timeout Protection: Automatically terminates runaway scripts or infinite loops to keep Neovim responsive.
  • πŸ“¦ Zero Heavy Dependencies: Simple Lua frontend paired with a standalone compiled Go binary.

πŸ—οΈ Architecture & How It Works

 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           TCP Socket           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚  Neovim Editor   β”‚ ─────────────────────────────> β”‚  Go Backend Server  β”‚
 β”‚ (Buffer Changes) β”‚     Payload: .py\n<code>        β”‚  (src/server :port) β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                                                     β”‚
          β”‚  Displays Output                                    β”‚ Executes via
          β–Ό                                                     β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ Live Output Splitβ”‚ <───────────────────────────── β”‚ Language Runtime    β”‚
 β”‚ (Scratch Buffer) β”‚        stdout / stderr         β”‚ (python, node, etc) β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Buffer Event: When text changes in an active supported buffer, Neovim triggers an autocommand.
  2. TCP Stream: The Lua client sends the file extension header and full buffer contents over TCP to 127.0.0.1:<port>.
  3. Debounced Execution: The Go server debounces incoming payloads, executes the code using the matching runtime, and captures output.
  4. Live Stream: Terminal output is streamed back to Neovim's LiveRunner Output split window in real time.

🌍 Supported Languages

Language Extension Default Runtime Command
Python .py python3
Go .go go run
Lua .lua lua
JavaScript .js node

βœ… Requirements

Before installing, ensure the following dependencies are available on your system path:

  • Neovim: >= 0.7.0
  • Go: >= 1.18 (Required to compile and run the backend server)
  • Language Runtimes:
    • Python: python3
    • Node.js: node (v16+)
    • Lua: lua (v5.1+)

πŸ“¦ Installation

return {
    "shadowmkj/nvim-live-runner",
    build = "cd src && go build -o server", -- Compiles backend server on install/update
    opts = {
        port = 65432,
    },
    config = function(_, opts)
        require("live-runner").setup(opts)
    end,
}
use {
    "shadowmkj/nvim-live-runner",
    run = "cd src && go build -o server",
    config = function()
        require("live-runner").setup({
            port = 65432,
        })
    end,
}
Plug 'shadowmkj/nvim-live-runner', { 'do': 'cd src && go build -o server' }

Manual Compilation

If you prefer to compile the backend server binary manually:

cd ~/.local/share/nvim/plugged/nvim-live-runner/src
go build -o server

πŸš€ Usage

Commands

Command Description
:LiveRun Starts the live runner server and opens the split output window.
:LiveRun stop Stops the live runner background process and closes the output split window.
:LiveRun numbers Toggles line numbers on or off in the live output split window.

Keymap Example

Add keybindings to your Neovim configuration (init.lua):

-- Toggle LiveRunner with <leader>lr and stop with <leader>lq
vim.keymap.set("n", "<leader>lr", "<cmd>LiveRun<cr>", { desc = "Start Live Runner" })
vim.keymap.set("n", "<leader>lq", "<cmd>LiveRun stop<cr>", { desc = "Stop Live Runner" })
vim.keymap.set("n", "<leader>ln", "<cmd>LiveRun numbers<cr>", { desc = "Toggle Output Line Numbers" })

βš™οΈ Configuration

Pass a configuration table to setup() to override default settings:

require("live-runner").setup({
    port = 65432,             -- TCP port for the server to listen on
    bin_path = nil,           -- Custom path to the server binary (defaults to plugin src/server)
    show_line_numbers = false, -- Display line numbers in the output window (default: false)
})

Configuration Options

Option Type Default Description
port number 65432 TCP port used for communication between Neovim and the Go backend.
bin_path `string nil` nil
show_line_numbers boolean false Controls whether line numbers are displayed in the split output window. Default is false (off).

Environment Variables

Variable Default Description
NLR_TIMEOUT_MS 2000 Code execution timeout in milliseconds before terminating long-running processes.

Example:

export NLR_TIMEOUT_MS=5000  # Sets timeout to 5 seconds

πŸ› Troubleshooting & FAQ

Q: Error LiveRunner: Server binary not found at ...

Solution: The backend Go binary hasn't been compiled yet. Run cd src && go build -o server inside the plugin installation directory.

Q: Code output isn't updating as I type

Solution: Ensure your file has a supported extension (.py, .go, .lua, or .js) and that the corresponding language runtime (python3, go, lua, node) is executable in your terminal $PATH.

Q: Port 65432 is already in use

Solution: Update the port number in your setup configuration:

require("live-runner").setup({ port = 54321 })

πŸ›£οΈ Roadmap

  • Support for temporary file execution across all interpreters.
  • Configurable output split position (bottom, right, or floating window).
  • Add support for Rust (rustc), C/C++ (gcc/clang), and TypeScript (tsx).
  • Statusline component integration (lualine.nvim).

❀️ Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.


πŸ“„ License

Distributed under the MIT License. See LICENSE for details.

Made with ❀️ by shadowmkj

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages