An Emacs package for interactively toggling Cargo features in Rust projects via LSP configuration.
2025-10-16.16-40-16.webm
- Find and parse
Cargo.tomlfiles - Interactive menu to toggle Cargo features
- Automatically updates
.dir-locals.elwith LSP configuration - Shows enabled features and their dependencies
- Supports toggling
no-default-features - Supports both
eglotandlsp-mode
Requires tomlparse.el, a tree-sitter based TOML parser that requires Emacs 29.1 or later.
Run M-x cargo-features-toggle-menu to open the interactive feature selection menu.
By default, the package uses eglot mode. To switch to lsp-mode, set:
(setq cargo-features-lsp-mode 'lsp-mode)When using eglot, the .dir-locals.el file is created at the project root (directory containing .git) with configuration in the format:
((rustic-mode . ((eglot-workspace-configuration
. (:rust-analyzer
(:cargo (:features ["feature1" "feature2"]
:noDefaultFeatures t)))))))When using lsp-mode, the .dir-locals.el file is created at the Cargo.toml directory with configuration in the format:
((rustic-mode . ((lsp-rust-features . ["feature1" "feature2"])
(lsp-rust-no-default-features . t))))