Enable Crate Features in Helix Editor With rust-analyzer
So you’re using helix, you’re working on a rust crate, and you need to turn a feature flag on. Here’s how:
- create a
.helix
folder in the project root. - create a file
.helix/languages.toml
. - In that file, put this in:
[[language]]
name = "rust"
config = { cargo = { features = [ "some_feature" ] } }
This will enable the feature! Restart helix (or reload config + restart lsp) and you’re good to go. You can also configure anything else you can find in rust-analyzer’s config docs because the config
object is just passed right on in to rust-analyzer as json. Just omit the leading rust-analyzer.
outer object when you’re putting stuff into the toml here.
If you want, you can also use this file to configure other helix settings on a per-project basis like disabling autoformat or setting indent levels or whatever.