I’m developing a Rust crate where GPU-dependent and GPU-independent parts are separated using features. By default, the GPU-related features are turned off, which leads to a poor development experience in GPU environments as rust-analyzer doesn’t function correctly. I use nvim.
I’m looking for a method that meets the following requirements:
- Ability to flexibly switch Rust features for each project
- Ensure that rust-analyzer recognizes the switched configuration
- Ability to change the default features setting at any time, depending on the development environment
Specifically, I’m considering methods such as:
- Using .cargo/config.toml
- Using bash scripts
- Using other configuration files or tools
Ideally, I’d like a mechanism where appropriate features are automatically set when entering the project directory, and rust-analyzer recognizes them.
If there are effective methods or best practices to achieve this, please let me know. I’m particularly interested in solutions that consider both rust-analyzer configuration and Cargo configuration.
For context, in my project, when I’m in a GPU environment, I want to enable GPU features for better IDE support, but I don’t want to change the default in Cargo.toml as it should remain GPU-optional for users.
Any insights or suggestions would be greatly appreciated!
5