https://github.com/johnsaigle/cargo-expand.nvim
A Neovim plugin for viewing expanded Rust.
https://github.com/johnsaigle/cargo-expand.nvim
cargo neovim neovim-plugin rust vim
Last synced: 2 months ago
JSON representation
A Neovim plugin for viewing expanded Rust.
- Host: GitHub
- URL: https://github.com/johnsaigle/cargo-expand.nvim
- Owner: johnsaigle
- Created: 2025-01-10T18:50:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-05T22:56:59.000Z (over 1 year ago)
- Last Synced: 2025-03-26T07:44:03.114Z (about 1 year ago)
- Topics: cargo, neovim, neovim-plugin, rust, vim
- Language: Lua
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cargo-expand.nvim
A Neovim plugin for viewing expanded Rust macros using `cargo expand`.
## Installation
Using [lazy.nvim](https://github.com/folke/lazy.nvim):
```lua
{
'johnsaigle/cargo-expand.nvim',
config = function()
require('cargo-expand').setup(}
end
}
```
## Usage
- Open neovim in the directory containing the appropriate `Cargo.toml` file.
- Place your cursor on any Rust identifier and run `:CargoExpand`.
This will:
- Run `cargo expand` on your project
- Switch to the expanded code in the current buffer
- Add all occurrences to the quickfix list
- Cache the expanded file
## Requirements
- Neovim >= 0.8.0
- `cargo-expand` tool (`cargo install cargo-expand`)
## TODO
The script could be improved by finding the 'closest' `Cargo.toml` file to the file in the current buffer.
This would make it so that neovim doesn't need to be launched from the directory that has the right Cargo.toml file.
- first check cwd
- if Cargo.toml is virtual manfiest, look at options in child directories
- otherwise, look at parent directory