kilbd / nova-rust

A Rust extension for the Nova text editor, using the Rust Analyzer language server.
MIT License
29 stars 5 forks source link

Let me choose Rustup/Cargo paths #37

Closed diktomat closed 1 year ago

diktomat commented 2 years ago

Is your feature request related to a problem? Please describe. As I like my dotfiles clean, I installed rustup and cargo to ~/.local, where it isn't detected unless the environment variables are set appropriately. This results in errors by this extension, see below. A Cargo.toml is actually there in the root directory of the project.

Describe the solution you'd like Let me choose Rustup/Cargo paths.

Describe alternatives you've considered Tried to set $RUSTUP_HOME/$CARGO_HOME env variables in the extension settings without effect.

Additional context Captured in the sample grep project from the Rust book for simplicity.

All used commands are actually installed:

❯ which rust-analyzer 
/opt/homebrew/bin/rust-analyzer

❯ which cargo
/Users/bene/.local/share/cargo/bin/cargo

❯ which rustfmt
/Users/bene/.local/share/cargo/bin/rustfmt

Errors:

image

Env vars in extension settings:

image

Project file tree:

image
kilbd commented 1 year ago

I'm not sure I understand this issue. This extension (and Rust Analyzer) assume that Cargo is on your $PATH, which looks to be the case since which is working as you expect. Could you be more descriptive as to what is failing?

diktomat commented 1 year ago

They're in PATH in my shell, but Nova/the extension don't eval my fish config, so their path is only the macOS standard one without additions for rust or cargo.

kilbd commented 1 year ago

Aha! Thanks for providing more details, I think I understand better. I looked and even if I had an extension preference for setting a custom Cargo path (which I'm not inclined to do), Rust Analyzer doesn't offer a way to configure it to use a custom Cargo path. I think the only recourse is to somehow set the $PATH in Nova.

Have you already tried adding PATH=$PATH:/Users/bene/.local/share/cargo/bin to the env vars in this extension's preferences? I can't be sure this would resolve correctly but it's worth trying first.

If you look in Nova Preferences -> Tools, you'll see this section:

Screenshot 2023-03-17 at 10 06 09 PM

You'll note it takes environment variables from your "login shell" which I assume you left as zsh, but below that is another place to add global environment variables, so if it didn't work for the extension preferences you could try again here.

A final option, which it sounds like you'll dislike, is to augment the $PATH in a dotfile that zsh will pick up.

diktomat commented 1 year ago

Nah, my login shell is Fish. But adding PATH manually works for me, thank you!