| Crates.io | cargo-nvim |
| lib.rs | cargo-nvim |
| version | 0.1.5 |
| created_at | 2025-01-18 03:05:36.918549+00 |
| updated_at | 2025-05-14 02:50:47.562911+00 |
| description | A Neovim plugin for Rust Cargo commands |
| homepage | |
| repository | https://github.com/nwiizo/cargo.nvim |
| max_upload_size | |
| id | 1521324 |
| size | 1,525,190 |
๐ฆ A Neovim plugin that provides seamless integration with Rust's Cargo commands. Execute Cargo commands directly from Neovim with a floating window interface.

{
"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",
"CargoRunTerm",
"CargoTest",
"CargoUpdate",
"CargoCheck",
"CargoClippy",
"CargoAdd",
"CargoRemove",
"CargoFmt",
"CargoFix"
}
}
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,
}
libluajit-5.1-dev (Install with sudo apt install libluajit-5.1-dev)luajit (Install with brew install luajit)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 in a floating window:CargoRunTerm - Run the project in terminal mode (better for interactive applications):CargoTest - Run tests:CargoUpdate - Update dependencies:CargoCheck - Check the project for errors:CargoClippy - Run the Clippy linter:CargoAdd - Add dependency:CargoRemove - Remove dependency:CargoFmt - Format code with rustfmt:CargoFix - Auto-fix warnings:CargoPublish - Publish package:CargoInstall - Install binary:CargoUninstall - Uninstall binary:CargoSearch - Search packages:CargoTree - Show dependency tree:CargoVendor - Vendor dependencies:CargoAudit - Audit dependencies:CargoOutdated - Check outdated dependencies:CargoAutodd - Automatically manage dependenciesYou 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")
wrap_output = true, -- Enable text wrapping in output window
show_line_numbers = true, -- Show line numbers in output window
show_cursor_line = true, -- Highlight current line in output window
-- Auto-close settings
auto_close = true, -- Auto close window on success
close_timeout = 5000, -- Close window after 5000ms
-- Timeout settings
run_timeout = 300, -- Timeout for cargo run in seconds
interactive_timeout = 30, -- Inactivity timeout for interactive mode
-- Advanced behavior options
force_interactive_run = true, -- Always treat cargo run as interactive mode
max_inactivity_warnings = 3, -- Maximum number of inactivity warnings before termination
detect_proconio = true, -- Enable detection of proconio usage
force_smart_detection = true, -- Always use smart detection for interactive programs
-- Key mappings (customizable)
keymaps = {
close = "q",
scroll_up = "<C-u>",
scroll_down = "<C-d>",
scroll_top = "gg",
scroll_bottom = "G",
interrupt = "<C-c>",
toggle_wrap = "w",
copy_output = "y",
clear_output = "c",
},
})
In the floating window:
q or <Esc> - Close the window<C-c> - Cancel the running command<C-u> - Scroll up<C-d> - Scroll downgg - Scroll to topG - Scroll to bottomw - Toggle text wrappingy - Copy all output to clipboardc - Clear outputFor interactive programs that require user input:
For highly interactive applications (e.g., using proconio or TUI applications):
:CargoRunTerm to run your application in a terminal emulator inside a floating window:CargoRun for interactive applicationsq or <Esc> - Close the window (after program completion)<C-\><C-n> - Switch to normal mode (while running)<C-c> - Send interrupt signal<C-d> - Send EOF signalContributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
This plugin is inspired by various Neovim plugins and the Rust community.