dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.57k stars 1.44k forks source link

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

Closed mathstuf closed 1 year ago

mathstuf commented 1 year ago

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 commented 1 year ago

Seems related to this https://github.com/rust-lang/rust-analyzer/issues/6007

Some notable take-aways from that thread:

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 commented 1 year ago

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 commented 1 year ago

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.".