rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.32k stars 1.61k forks source link

VS Code Extension Config API #18476

Open alexander-heimbuch opened 2 weeks ago

alexander-heimbuch commented 2 weeks ago

Our VS Code extension integrates with the Rust Analyzer extension. In order for Rust Analyzer to work in our environment, it needs dynamic values in the configuration. So far we update the settings.json according to the dynamic values, but this leads to overwriting any configurations of the user and leaving the workspace in a potential dirty state. Accordingly, a different configuration interface would be desirable.

VS Code Extensions offer the possibility to expose an API via the activate hook, here a config function could be added, which enables a configuration in an extension to extension communication:

const rustAnalyzer = vscode.extensions.getExtension("rust-lang.rust-analyzer")?.exports;

await rustAnalyzer.config({ ... });

This function should respect the existing configuration (user configurations have precedence).