This project is currently not intended to run large projects but is perfect for performance testing or troubleshooting.
If you just need to run some code quickly this plugin could be for you
Just install it using your favorite plugin manager.
Calling the setup function is not required, it is necessary if you want to add languages to the already supported list
use {
"vzytoi/runcode.nvim",
config = function()
require('runcode').setup {
Interpret = {
ocaml = "ocaml %",
},
Compile = {
ocaml = "ocamlc % -o #@ && #@",
c = "gcc % -o $ && $"
}
}
end
}-- If no method is specified,
-- a command will be searched in both starting with the interpretation.
vim.keymap.set("n", "<leader>x", function()
require('runcode').run {
dir = "horizontal"
}
end)
-- If no direction is specified, runcode
-- will be executed horizontally.
vim.keymap.set("n", "<leader>xx", function()
require('runcode').run { method = "project" }
end)
-- run {
-- method = "Project" | "Interpret" | "Compile" | nil
-- dir = "vertical" | "horizontal" | "tab" | nil
-- cd = true | false
-- save = true | false
-- }
In some cases, execute a file won't work if your current directory isn't the same as your current
file's directory. Thus by default, runcode will cd into your current file's directory. If you want to disable
this behavior, you can set cd = false in the run function.
By default runcode will automatically save your current file before running it.
You can of course disable this behavior by setting save = false in the run function.
Here is the list of languages already supported.
Of course all of them can be overridden and others added.
| Language | Interpret | Compile | Project |
|---|---|---|---|
| typescript | ts-node % | ✖ | ✖ |
| javascript | node % | ✖ | node ^ |
| go | go run % | go build -o #@ % && #@ | ✖ |
| php | php % | ✖ | ✖ |
| python | python3 % | ✖ | ✖ |
| lua | lua % | ✖ | ✖ |
| c | ✖ | gcc % -o #@ && #@ | gcc ^ % -o #@ && #@ |
| rust | ✖ | rustc % -o #@ && #@ | ✖ |
| html | open % | ✖ | ✖ |
| ocaml | ocaml % | ocamlc % -o #@ && #@ | dune exec ^ |
| ruby | ruby % | ✖ | ✖ |
| sh | sh % | ✖ | ✖ |
As shown in the installation section, call the setup function and add the languages you want.
Here are the expressions being substituted
| Expression | Substitution |
|---|---|
| % | vim.fn.expand('%:p') |
| @ | vim.fn.expand('%:t:r') |
| # | vim.fn.stdpath('data')..'/rooter/' |
| ^ | project name if found |
The # expression should be use to store executables before execution.
If an expression is missing, make an issue or a pull request.
The expression list can be found in runcode/parser.lua.
Four highlights can be configured to match your needs:
RunCodeNormal: Window's backgroundRunCodeOk: color of the message in lack of errorsRunCodeError: Color of the message if an error is foundRunCodeInfo: The top message with the execution time and the number of lines
- Automatic project detection.
- More language support
- Aesthetic loading
- Compile xor interpret languages supporting it