This is a Neovim plugin that was inspired by the TJ Devries YouTube videos Automatically Execute Anything in Nvim and Execute anything in neovim (now customizable).
This creates the user commands "BufNum" and "AutoRun". To use them:
- Open a source file that can be executed by some shell command.
- Enter
:vnew
to open an empty buffer in a vertical split. - Enter
:BufNum
to get the number of the empty buffer. - Enter
:AutoRun
which will prompt for three things. - Enter the buffer number that was output in step 3.
- Enter a pattern that matches files that should trigger a run.
For example,
*.lua
. - Enter a command to run that builds and runs a program.
For example,
lua main.lua
.
This will run the command immediately and again every time a file that matches the pattern is saved, the command will be executed. Its output, both stdout and stderr, will be displayed in the buffer in the vertical split.
Using the example values above, saving any .lua
file
will cause the command lua main.lua
to execute again.
This is good because it is possible that main.lua
uses (requires) other .lua
files.