nvim-fuel is a Neovim plugin for running a main or script in several languages. This is meant to be useful for practicing and maybe teaching.
- To use this plugin in a particular language, the compiler or language itself needs to be installed.
- Supported languages are: Assembly, C, C++, Clojure, Go, Haskell, Java, Kotlin, Lua, Python, Rust, Scala, Scheme and Zig
- Posibility to add custom language implementations
- This plugin has been developed on and for Linux following open source philosophies.
Feature | nvim-fuel | NOTE |
---|---|---|
Command to show results in Fuel Console | ✔️ | Set by Fuel |
Command to close Fuel Console | ✔️ | Set by FuelStop |
Execution in Normal Mode | ✔️ | Set by Fuel |
Execution in Insert Mode | ✔️ | Set by Fuel |
Console size configurable | ✔️ | By setup |
Autosave configurable | ✔️ | By setup |
Supports different languages in same window (different buffers) | ✔️ | |
Supports custom language implementations | ✔️ | |
Main arguments | ❌ | |
Stdin | ✔️ | |
Popup console | ✔️ | By setup |
Packer
use {
'javiorfo/nvim-fuel',
requires = 'javiorfo/nvim-popcorn'
}
Lazy
{
'javiorfo/nvim-fuel',
lazy = true,
dependencies = { 'javiorfo/nvim-popcorn' },
-- ft could contain only the languages nvim-fuel will be used for
ft = { "asm", "c", "cpp", "clojure", "go", "haskell", "java", "kotlin", "lua", "python", "rust", "scala", "scheme", "zig" },
opts = {
-- Not necessary. Only if you want to change the setup
view = {
-- Default console size (this applies to popup size too)
console_size = 10,
-- Default autosave before pressing the Fuel shortcut
autosave = true,
-- Default false. If you want to show the console in a popup instead of a buffer
popup = false
}
},
keys = {
{ "<leader>fu", "<Plug>Fuel" },
{ "<leader>fs", "<Plug>FuelStop" }
}
}
- Set mappings in init.vim or init.lua
local opts = { noremap = true, silent = true }
-- Normal mode
vim.api.nvim_set_keymap('n', '<leader>fu', '<Plug>Fuel', opts)
vim.api.nvim_set_keymap('n', '<leader>fs', '<Plug>FuelStop<CR>', opts)
- Only the installation step is required to use this plugin, but you can modify this options if you like:
require'fuel'.setup{
view = {
-- Default console size (this applies to popup size too)
console_size = 10,
-- Default autosave before pressing the Fuel shortcut
autosave = true,
-- Default false. If you want to show the console in a popup instead of a buffer
popup = false
},
-- Override language implementations or implement a missing language
language_implementations = {
-- C example
c = {
-- Required build function
-- file_with_extension is this case will be 'file_name.c'
-- file is this case will be 'file_name'
build = function (file_with_extension, file)
vim.cmd("autocmd BufDelete c_fuel_main_console silent !rm -f " .. file)
return string.format("gcc -Wall %s -o /tmp/%s && /tmp/%s && rm -f /tmp/%s 2> /dev/null", file_with_extension, file, file, file)
end,
-- Required statusline function
-- This will print on cmd statusline after build is executed
get_statusline = function(file)
return util.statusline_style(" C", file)
end,
-- Required get_footer function
-- This will print on footer popup after build is executed
get_footer = function(file)
return util.footer(" C", file)
end
}
}
}
- Executing the map corresponding to
Fuel
in a main or scripting file, it will compile and execute the aforementioned file opening a console ouput. - Execute the map corresponding to
FuelStop
to close all open Fuel console. In case you are usingpopup = true
just press - To see the execution string use the command
:FuelInfo
which will open a popup with info
NOTE: The colorscheme nebula from nvim-nyctophilia is used in this image.