diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index f4c15405898..b19421c16e7 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -18,13 +18,13 @@ pub struct Config { pub client_caps: ClientCapsConfig, pub with_sysroot: bool, + // TODO: verify that it means what I think it means pub publish_diagnostics: bool, - pub use_client_watching: bool, // TODO: move to experimental capabilities pub vscode_lldb: bool, pub lru_capacity: Option, pub proc_macro_srv: Option, - pub exclude_globs: Vec, + pub files: FilesConfig, pub notifications: NotificationsConfig, pub cargo: CargoConfig, @@ -36,6 +36,18 @@ pub struct Config { pub call_info_full: bool, } +#[derive(Debug, Clone)] +pub struct FilesConfig { + watcher: FilesWatcher, + exclude: Vec, +} + +#[derive(Debug, Clone)] +enum FilesWatcher { + Client, + Notify, +} + #[derive(Debug, Clone)] pub struct NotificationsConfig { pub workspace_loaded: bool, @@ -67,11 +79,10 @@ impl Default for Config { with_sysroot: true, publish_diagnostics: true, - use_client_watching: false, vscode_lldb: false, lru_capacity: None, proc_macro_srv: None, - exclude_globs: Vec::new(), + files: FilesConfig { watcher: FilesWatcher::Notify, exclude: Vec::new() }, notifications: NotificationsConfig { workspace_loaded: true, cargo_toml_not_found: true, @@ -112,39 +123,43 @@ impl Config { set(value, "/withSysroot", &mut self.with_sysroot); set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); - set(value, "/useClientWatching", &mut self.use_client_watching); set(value, "/vscodeLldb", &mut self.vscode_lldb); set(value, "/lruCapacity", &mut self.lru_capacity); - set(value, "/excludeGlobs", &mut self.exclude_globs); - set(value, "/featureFlags/notifications.workspace-loaded", &mut self.notifications.workspace_loaded); - set(value, "/featureFlags/notifications.cargo-toml-not-found", &mut self.notifications.cargo_toml_not_found); - - set(value, "/cargoFeatures/noDefaultFeatures", &mut self.cargo.no_default_features); - set(value, "/cargoFeatures/allFeatures", &mut self.cargo.all_features); - set(value, "/cargoFeatures/features", &mut self.cargo.features); - set(value, "/cargoFeatures/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); - if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { - set(value, "/rustfmtArgs", extra_args); + if let Some(watcher) = get::(value, "/files/watcher") { + self.files.watcher = match watcher.as_str() { + "client" => FilesWatcher::Client, + "notify"| _ => FilesWatcher::Notify, + } } - if let Some(false) = get(value, "cargo_watch_enable") { + set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded); + set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found); + + set(value, "/cargo/noDefaultFeatures", &mut self.cargo.no_default_features); + set(value, "/cargo/allFeatures", &mut self.cargo.all_features); + set(value, "/cargo/features", &mut self.cargo.features); + set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); + if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { + set(value, "/rustfmt/extraArgs", extra_args); + } + if let Some(false) = get(value, "/checkOnSave/enable") { self.check = None } else { if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check { - set(value, "/cargoWatchArgs", extra_args); - set(value, "/cargoWatchCommand", command); - set(value, "/cargoWatchAllTargets", all_targets); + set(value, "/checkOnSave/extraArgs", extra_args); + set(value, "/checkOnSave/command", command); + set(value, "/checkOnSave/allTargets", all_targets); } }; - set(value, "/inlayHintsType", &mut self.inlay_hints.type_hints); - set(value, "/inlayHintsParameter", &mut self.inlay_hints.parameter_hints); - set(value, "/inlayHintsChaining", &mut self.inlay_hints.chaining_hints); - set(value, "/inlayHintsMaxLength", &mut self.inlay_hints.max_length); - set(value, "/featureFlags/completion.enable-postfix", &mut self.completion.enable_postfix_completions); - set(value, "/featureFlags/completion.insertion.add-call-parenthesis", &mut self.completion.add_call_parenthesis); - set(value, "/featureFlags/completion.insertion.add-argument-snippets", &mut self.completion.add_call_argument_snippets); - set(value, "/featureFlags/call-info.full", &mut self.call_info_full); + set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); + set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); + set(value, "/inlayHints/chainingHints", &mut self.inlay_hints.chaining_hints); + set(value, "/inlayHints/maxLength", &mut self.inlay_hints.max_length); + set(value, "/completion/postfix/enable", &mut self.completion.enable_postfix_completions); + set(value, "/completion/addCallParenthesis", &mut self.completion.add_call_parenthesis); + set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets); + set(value, "/callInfo/full", &mut self.call_info_full); log::info!("Config::update() = {:#?}", self); diff --git a/editors/code/package.json b/editors/code/package.json index 946145df80b..df8adfe0e17 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -177,46 +177,153 @@ "type": "object", "title": "Rust Analyzer", "properties": { + "rust-analyzer.diagnostics.enable": { + "type": "boolean", + "default": true, + "markdownDescription": "Whether to show native rust-analyzer diagnostics." + }, + "rust-analyzer.lruCapacity": { + "type": [ + "null", + "integer" + ], + "default": null, + "minimum": 0, + "exclusiveMinimum": true, + "description": "Number of syntax trees rust-analyzer keeps in memory." + }, + "rust-analyzer.files.watcher": { + "type": "string", + "enum": [ + "client", + "notify" + ], + "default": "client", + "description": "Controls file watching implementation." + }, + "rust-analyzer.files.exclude": { + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "description": "Paths to exclude from analysis." + }, + "rust-analyzer.notifications.workspaceLoaded": { + "type": "boolean", + "markdownDescription": "Whether to show `workspace loaded` message." + }, + "rust-analyzer.notifications.cargoTomlNotFound": { + "type": "boolean", + "markdownDescription": "Whether to show `can't find Cargo.toml` error message" + }, + + "rust-analyzer.cargo.noDefaultFeatures": { + "type": "boolean", + "default": false, + "markdownDescription": "Do not activate the `default` feature" + }, + "rust-analyzer.cargo.allFeatures": { + "type": "boolean", + "default": true, + "description": "Activate all available features" + }, + "rust-analyzer.cargo.features": { + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "description": "List of features to activate" + }, + "rust-analyzer.cargo.loadOutDirsFromCheck": { + "type": "boolean", + "default": false, + "markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs" + }, + "rust-analyzer.rustfmt.extraArgs": { + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "description": "Additional arguments to rustfmt" + }, + "rust-analyzer.checkOnSave.enable": { + "type": "boolean", + "default": true, + "markdownDescription": "Run specified `cargo check` command for diagnostics on save" + }, + "rust-analyzer.checkOnSave.extraArgs": { + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "Extra arguments for `cargo check`", + "default": [] + }, + "rust-analyzer.checkOnSave.command": { + "type": "string", + "default": "check", + "markdownDescription": "Cargo command to use for `cargo check`" + }, + "rust-analyzer.checkOnSave.allTargets": { + "type": "boolean", + "default": true, + "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" + }, + + "rust-analyzer.inlayHints.typeHints": { + "type": "boolean", + "default": true, + "description": "Whether to show inlay type hints" + }, + "rust-analyzer.inlayHints.chainingHints": { + "type": "boolean", + "default": true, + "description": "Whether to show inlay type hints for method chains" + }, + "rust-analyzer.inlayHints.parameterHints": { + "type": "boolean", + "default": true, + "description": "Whether to show function parameter name inlay hints at the call site" + }, + "rust-analyzer.inlayHints.maxLength": { + "type": [ + "null", + "integer" + ], + "default": 20, + "minimum": 0, + "exclusiveMinimum": true, + "description": "Maximum length for inlay hints" + }, + + "rust-analyzer.completion.addCallParenthesis": { + "type": "boolean", + "default": true, + "description": "Whether to add parenthesis when completing functions" + }, + "rust-analyzer.completion.addCallArgumentSnippets": { + "type": "boolean", + "default": true, + "description": "Whether to add argument snippets when completing functions" + }, + "rust-analyzer.completion.postfix.enable": { + "type": "boolean", + "default": true, + "markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." + }, + "rust-analyzer.callInfo.full": { + "type": "boolean", + "description": "Show function name and docs in parameter hints" + }, + "rust-analyzer.highlighting.semanticTokens": { "type": "boolean", "default": false, "description": "Use proposed semantic tokens API for syntax highlighting" }, - "rust-analyzer.featureFlags": { - "type": "object", - "default": {}, - "description": "Fine grained feature flags to disable annoying features", - "properties": { - "lsp.diagnostics": { - "type": "boolean", - "markdownDescription": "Whether to show diagnostics from `cargo check`" - }, - "completion.insertion.add-call-parenthesis": { - "type": "boolean", - "description": "Whether to add parenthesis when completing functions" - }, - "completion.insertion.add-argument-snippets": { - "type": "boolean", - "description": "Whether to add argument snippets when completing functions" - }, - "completion.enable-postfix": { - "type": "boolean", - "markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." - }, - "call-info.full": { - "type": "boolean", - "description": "Show function name and docs in parameter hints" - }, - "notifications.workspace-loaded": { - "type": "boolean", - "markdownDescription": "Whether to show `workspace loaded` message" - }, - "notifications.cargo-toml-not-found": { - "type": "boolean", - "markdownDescription": "Whether to show `can't find Cargo.toml` error message" - } - } - }, "rust-analyzer.updates.channel": { "type": "string", "enum": [ @@ -243,50 +350,6 @@ "default": null, "description": "Path to rust-analyzer executable (points to bundled binary by default). If this is set, then \"rust-analyzer.updates.channel\" setting is not used" }, - "rust-analyzer.excludeGlobs": { - "type": "array", - "items": { - "type": "string" - }, - "default": [], - "description": "Paths to exclude from analysis" - }, - "rust-analyzer.rustfmtArgs": { - "type": "array", - "items": { - "type": "string" - }, - "default": [], - "description": "Additional arguments to rustfmt" - }, - "rust-analyzer.useClientWatching": { - "type": "boolean", - "default": true, - "description": "client provided file watching instead of notify watching." - }, - "rust-analyzer.cargo-watch.enable": { - "type": "boolean", - "default": true, - "markdownDescription": "Run specified `cargo-watch` command for diagnostics on save" - }, - "rust-analyzer.cargo-watch.arguments": { - "type": "array", - "items": { - "type": "string" - }, - "markdownDescription": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )", - "default": [] - }, - "rust-analyzer.cargo-watch.command": { - "type": "string", - "markdownDescription": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )", - "default": "check" - }, - "rust-analyzer.cargo-watch.allTargets": { - "type": "boolean", - "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)", - "default": true - }, "rust-analyzer.trace.server": { "type": "string", "scope": "window", @@ -308,64 +371,6 @@ "type": "boolean", "default": false }, - "rust-analyzer.lruCapacity": { - "type": [ - "null", - "integer" - ], - "default": null, - "minimum": 0, - "exclusiveMinimum": true, - "description": "Number of syntax trees rust-analyzer keeps in memory" - }, - "rust-analyzer.inlayHints.typeHints": { - "type": "boolean", - "default": true, - "description": "Whether to show inlay type hints" - }, - "rust-analyzer.inlayHints.chainingHints": { - "type": "boolean", - "default": true, - "description": "Whether to show inlay type hints for method chains" - }, - "rust-analyzer.inlayHints.parameterHints": { - "type": "boolean", - "default": true, - "description": "Whether to show function parameter name inlay hints at the call site" - }, - "rust-analyzer.inlayHints.maxLength": { - "type": [ - "null", - "integer" - ], - "default": 20, - "minimum": 0, - "exclusiveMinimum": true, - "description": "Maximum length for inlay hints" - }, - "rust-analyzer.cargoFeatures.noDefaultFeatures": { - "type": "boolean", - "default": false, - "markdownDescription": "Do not activate the `default` feature" - }, - "rust-analyzer.cargoFeatures.allFeatures": { - "type": "boolean", - "default": true, - "description": "Activate all available features" - }, - "rust-analyzer.cargoFeatures.features": { - "type": "array", - "items": { - "type": "string" - }, - "default": [], - "description": "List of features to activate" - }, - "rust-analyzer.cargoFeatures.loadOutDirsFromCheck": { - "type": "boolean", - "default": false, - "markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs" - } } }, "problemPatterns": [