An open API service indexing awesome lists of open source software.

https://github.com/nwiizo/cargo.nvim

A Neovim plugin that provides seamless integration with Rust's Cargo commands. Execute Cargo commands directly from Neovim with a floating window interface.
https://github.com/nwiizo/cargo.nvim

lua neovim neovim-plugin rust rust-lang

Last synced: 18 days ago
JSON representation

A Neovim plugin that provides seamless integration with Rust's Cargo commands. Execute Cargo commands directly from Neovim with a floating window interface.

Awesome Lists containing this project

README

        

# ๐Ÿš€ cargo.nvim

[![Rust CI](https://github.com/nwiizo/cargo.nvim/actions/workflows/rust.yml/badge.svg)](https://github.com/nwiizo/cargo.nvim/actions/workflows/rust.yml)
[![Lua CI](https://github.com/nwiizo/cargo.nvim/actions/workflows/lua.yml/badge.svg)](https://github.com/nwiizo/cargo.nvim/actions/workflows/lua.yml)

---

๐Ÿ“ฆ A Neovim plugin that provides seamless integration with Rust's Cargo commands. Execute Cargo commands directly from Neovim with a floating window interface.

![cargo.nvim demo](.github/cargo.nvim.gif)

## โœจ Features

- ๐Ÿ”ง 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

## contents

- [๐Ÿš€ cargo.nvim](#-cargonvim)
- [โœจ Features](#-features)
- [๐Ÿ“ฅ Installation](#-installation)
- [Using lazy.nvim](#using-lazynvim)
- [Using packer.nvim](#using-packernvim)
- [๐Ÿ“‹ Requirements](#-requirements)
- [๐Ÿ› ๏ธ Available Commands](#๏ธ-available-commands)
- [โš™๏ธ Configuration](#๏ธ-configuration)
- [โŒจ๏ธ Key Mappings](#๏ธ-key-mappings)
- [๐Ÿ‘ฅ Contributing](#-contributing)
- [๐Ÿ“œ License](#-license)
- [๐Ÿ’ Acknowledgements](#-acknowledgements)

## ๐Ÿ“ฅ Installation

### Using [lazy.nvim](https://github.com/folke/lazy.nvim)

```lua
{
"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](https://github.com/wbthomason/packer.nvim)

```lua
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,
}
```

## ๐Ÿ“‹ Requirements

- ๐Ÿ’ป Neovim >= 0.9.0
- ๐Ÿฆ€ Rust and Cargo installed on your system
- ๐Ÿ“š Additional dependencies:
- **Ubuntu/Debian:** `libluajit-5.1-dev` (Install with `sudo apt install libluajit-5.1-dev`)
- For other Linux distributions, you may need to install an equivalent LuaJIT development package

If you encounter build errors mentioning `lluajit-5.1` during installation, you likely need to install the LuaJIT development package for your system.

## ๐Ÿ› ๏ธ Available Commands

- ๐Ÿ“Š `: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

## โš™๏ธ Configuration

You can customize cargo.nvim by passing options to the setup function:

```lua
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 = "*" },
}
})
```

## โŒจ๏ธ Key Mappings

In the floating window:
- `q` or `` - Close the window
- `` - Cancel the running command and close the window

## ๐Ÿ‘ฅ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. ๐Ÿด Fork the repository
2. ๐ŸŒฟ Create a feature branch
3. โœ๏ธ Commit your changes
4. ๐Ÿš€ Push to the branch
5. ๐Ÿ“ซ Open a Pull Request

## ๐Ÿ“œ License

MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ’ Acknowledgements

This plugin is inspired by various Neovim plugins and the Rust community.

## ๐ŸŽ‰ Related Projects

- [cargo-autodd](https://github.com/nwiizo/cargo-autodd)