Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extraEnv in rust-anaylzer to define rustflags #14334

Open
1 task done
tomocrafter opened this issue Jul 12, 2024 · 6 comments
Open
1 task done

extraEnv in rust-anaylzer to define rustflags #14334

tomocrafter opened this issue Jul 12, 2024 · 6 comments
Labels
documentation [core label] rust Rust programming language support

Comments

@tomocrafter
Copy link

Check for existing issues

  • Completed

Describe the feature

In vscode version rust-analyzer, you can specify env in rust-analyzer.cargo.extraEnv to define rustflags to be used while analyzing workspace.

How can I specify rustflags in zed?

https://rust-analyzer.github.io/manual.html

If applicable, add mockups / screenshots to help present your vision of the feature

No response

@SomeoneToIgnore
Copy link
Contributor

Zed uses something similar but with a more convoluted syntax due to historic reasons unfortunately.
https://zed.dev/docs/languages/rust has some examples, and similar section could be created for cargo.

@notpeter notpeter added documentation [core label] rust Rust programming language support and removed enhancement [core label] triage labels Jul 13, 2024
@notpeter
Copy link
Member

@SomeoneToIgnore Is there any way to define rustflags for rust-analyzer.server.extraEnv or rust-analyzer.cargo.extraEnv currently?

@SomeoneToIgnore
Copy link
Contributor

No clue.

@djmaze
Copy link

djmaze commented Sep 15, 2024

This prevents working on wasm projects which use the web_sys_unstable_apis flag, because the analyzer bails out on the use of those unstable features / classes.

@djmaze
Copy link

djmaze commented Sep 15, 2024

Okay, I could make it work by setting the correct RUSTFLAGS as an env variable in the terminal and then starting zed from there.

(To be more precise, I was using a shell.nix which sets up the environment. I added a setting for RUSTFLAGS there.)

@aurexav
Copy link
Contributor

aurexav commented Sep 19, 2024

I simply adhere to the format and import the VSCode configuration. It appears to function correctly.

"lsp": {
	"rust-analyzer": {
		"initialization_options": {
			"cargo": {
				"buildScripts": {
					"enable": false
				}
			},
			"check": {
				"command": "clippy",
				"features": "all"
			},
			"checkOnSave": false,
			"completion": {
				"autoimport": {
					"enable": false
				}
			},
			"diagnostics": {
				"enable": false
			},
			"lens": {
				"debug": {
					"enable": false
				}
			},
			"notifications": {
				"cargoTomlNotFound": false
			},
			"rustfmt": {
				"extraArgs": ["+nightly"]
			}
		}
	}
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation [core label] rust Rust programming language support
Projects
None yet
Development

No branches or pull requests

5 participants