test.mp4
This is a Neovim plugin that allows you to run code in various languages directly from your editor. It supports a wide range of languages out of the box and can be easily extended to support more.
You can install this plugin with your favorite plugin manager. Here's an example using lazy.nvim
:
{
{
"blurskye/code-runner.nvim",
dependencies = {
"akinsho/toggleterm.nvim",
},
config = function()
require('code-runner').setup({
-- configuration options
})
end,
},
}
You can configure this plugin by calling the setup
function. Here's an example configuration with all available options:
require('code-runner').setup({
keymap = '<F5>', -- Keymap to run the code. Default is '<F5>'.
-- it has a lot of language run commands by default, can add or overwrite them as needed like this
commands = { -- Custom commands for languages.
python = "python3 -u $dir/$fileName",
},
extensions = { -- File extensions for languages.
python = { "py" },
},
run_tmux = false, -- If true, runs 'tmux new-session -A -s nvim' and 'ToggleTerm'. Default is false.
})
for beginners
After you've set up the plugin, you can run your code by pressing the keymap you've set in the configuration (default is <F5>
). The plugin will run the appropriate command for the language of the current file.
but for people who need a bit more juice out of the plugin
- it is multi modal
-
- it searchs in the script dir for a coderun.json file, expects it to be in the following format
{
"run the project"{
"command":"npm run start",
"keybind": "<F5>"
},
"deploy the project":{
"command" : "npm run deploy",
"keybind":"<F6>"
}
-- $dir uses the coderun.json's directory and rest of the coderun variables are the same as the currently open script
}
-
- However if a coderun.json is not found, it will defualt to language default to run the code, in which case it can be the ones passed in setup function(it overwrites the ones set by default in app)