An Emacs-style scratch buffer for executing Lua inside Neovim. replua.nvim opens a dedicated buffer where you can experiment with Lua, call any Neovim API, and see results printed inline -- much like the classic Emacs Lisp interaction mode.
- Opens a scratch buffer (replua://scratch) with Neovim APIs and the current global environment available.
- Evaluate the current line, surrounding block, or the whole buffer.
- Captures both returned values and print() output, appending results as Lua comments.
- Each scratch buffer owns its own Lua environment. Close a buffer (or open a new one with :RepluaOpen!) to start from a clean slate without affecting other replua instances.
If you prefer to manage configuration manually, require the plugin somewhere in your startup files:
The bundled plugin/replua.lua file calls setup() on load, so the commands are available even without manual configuration.
Open the scratch buffer with:
Need another scratch buffer? Run :RepluaOpen! for a fresh instance.
The default keymaps inside the buffer mirror Emacs-style interactions:
| <localleader>e | n | Evaluate the current line |
| <localleader><CR> | n | Evaluate the surrounding block |
| <localleader>r | n | Evaluate the entire scratch buffer |
Each evaluation appends comment lines such as -- => result or -- print: output, and drops you onto a new blank line ready for more Lua.
Additional commands:
- :RepluaEval — Evaluate the entire scratch buffer.
- :RepluaOpen! — Create a new replua buffer with a fresh environment.
- :RepluaReset — Reset the Lua environment used for evaluation.
Because the environment proxies _G, anything you define becomes available to Neovim instantly. For example:
Customize behaviour through setup():
Any option may be omitted to keep the defaults. Tables are merged, so redefining a single keymap leaves the others untouched.
.png)

