Ruby_runner_nvim
This is a non-technical explanation of how a code-runner mapping should work with Nvim. No code either.
- map F9 (normal mode)
- open a split (keep reference)
- run the code in the split
- in split buffer.. define two new mappings:
<esc>(terminal mode)<esc>(normal mode)
- both escape-mappings call ‘cleanup’.. that closes the split and destroys the buffer.
This allows you to close the split regardless on if the execution of the script succeeded or failed.
- You can check that the file is a ruby file before running the script.
- You can autosave the script before running (if you want).
Now:
F9 runs a ruby script and shows the output in a split below (output or error).
esc will close the split; destroy the extra buffer and return to your code.