π¦ A Neovim plugin that provides seamless integration with Rust's Cargo commands. Execute Cargo commands directly from Neovim with a floating window interface.
- π§ Execute Cargo commands directly from Neovim
- πͺ Real-time output in floating windows
- π¨ Syntax highlighting for Cargo output
- β‘ Asynchronous command execution
- π Auto-closing windows on command completion
- β¨οΈ Easy keyboard shortcuts for window management
Using lazy.nvim
{
"nwiizo/cargo.nvim",
build = "cargo build --release",
config = function()
require("cargo").setup({
float_window = true,
window_width = 0.8,
window_height = 0.8,
border = "rounded",
auto_close = true,
close_timeout = 5000,
})
end,
ft = { "rust" },
cmd = {
"CargoBench",
"CargoBuild",
"CargoClean",
"CargoDoc",
"CargoNew",
"CargoRun",
"CargoTest",
"CargoUpdate"
}
}
Using packer.nvim
use {
"nwiizo/cargo.nvim",
run = "cargo build --release",
config = function()
require("cargo").setup({
float_window = true,
window_width = 0.8,
window_height = 0.8,
border = "rounded",
auto_close = true,
close_timeout = 5000,
})
end,
}
- π» Neovim >= 0.9.0
- π¦ Rust and Cargo installed on your system
- π Additional dependencies:
- Ubuntu/Debian:
libluajit-5.1-dev
(Install withsudo apt install libluajit-5.1-dev
) - For other Linux distributions, you may need to install an equivalent LuaJIT development package
- Ubuntu/Debian:
If you encounter build errors mentioning lluajit-5.1
during installation, you likely need to install the LuaJIT development package for your system.
- π
:CargoBench
- Run benchmarks - ποΈ
:CargoBuild
- Build the project - π§Ή
:CargoClean
- Remove generated artifacts - π
:CargoDoc
- Generate project documentation - β¨
:CargoNew
- Create a new Cargo project βΆοΈ :CargoRun
- Run the project- π§ͺ
:CargoTest
- Run tests - π
:CargoUpdate
- Update dependencies - π€
:CargoAutodd
- Automatically manage dependencies
You can customize cargo.nvim by passing options to the setup function:
require("cargo").setup({
-- Window settings
float_window = true, -- Use floating window
window_width = 0.8, -- Window width (80% of editor width)
window_height = 0.8, -- Window height (80% of editor height)
border = "rounded", -- Border style ("none", "single", "double", "rounded")
-- Auto-close settings
auto_close = true, -- Auto close window on success
close_timeout = 5000, -- Close window after 5000ms
-- Command settings
commands = {
bench = { nargs = "*" }, -- Command arguments configuration
build = { nargs = "*" },
clean = { nargs = "*" },
doc = { nargs = "*" },
new = { nargs = 1 },
run = { nargs = "*" },
test = { nargs = "*" },
update = { nargs = "*" },
}
})
In the floating window:
q
or<Esc>
- Close the window<C-c>
- Cancel the running command and close the window
Contributions are welcome! Please feel free to submit a Pull Request.
- π΄ Fork the repository
- πΏ Create a feature branch
- βοΈ Commit your changes
- π Push to the branch
- π« Open a Pull Request
MIT License - see the LICENSE file for details.
This plugin is inspired by various Neovim plugins and the Rust community.