Skip to content

Support --target-dir with rust-analyzer #4557

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

Closed
mathstuf opened this issue Jul 17, 2023 · 3 comments · Fixed by #4559
Closed

Support --target-dir with rust-analyzer #4557

mathstuf opened this issue Jul 17, 2023 · 3 comments · Fixed by #4559

Comments

@mathstuf
Copy link
Contributor

rust-analyzer currently locks the default build directory. It'd be nice to be able to use a different directory to avoid cargo commands blocking rust-analyzer and vice versa. I've tried adding things to g:ale_rust_analyzer_config, but I wasn't able to plumb through the --target-dir setting.

@pbnj
Copy link
Contributor

pbnj commented Jul 20, 2023

Seems related to this rust-lang/rust-analyzer#6007

Some notable take-aways from that thread:

  • Try setting the config option { "rust-analyzer.server.extraEnv": { "CARGO_TARGET_DIR": "target/analyzer" } }
  • Set rust-analyzer.check.extraArgs configuration option to use the same target directory, like: ["--target-dir=target/analyzer"] (see rust-analyzer configuration docs for details)

In ALE, the configuration would look something like this:

let g:g:ale_rust_analyzer_config = {
  \ 'server': { 'extraEnv': { 'CARGO_TARGET_DIR': 'target/analyzer' } },
  \ 'check': { 'extraArgs': ["--target-dir=target/analyzer"] },
  \ }

Give this a try and let us know.

@mathstuf
Copy link
Contributor Author

Ah, I missed the extra layer there. I had tried:

let g:ale_rust_analyzer_config = {
\  'rust-analyzer.server.extraEnv': {
\    'CARGO_TARGET_DIR': 'target/analyzer'
\  }
\}

@mathstuf
Copy link
Contributor Author

That works, thanks. I'll see if I can improve the docs for that instead of just being "Dictionary with configuration settings for rust-analyzer.".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants