about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-18 16:41:26 +0000
committerbors <bors@rust-lang.org>2022-07-18 16:41:26 +0000
commitfac6a646566819bc9daa89de990281420cc1b01f (patch)
tree30b261271bf12388e611fa7a0ebd2d8add74dca1
parent22e53f1d33ec7be6ed0fce499166a90694fd068e (diff)
parentec1142c0d0de39c6e936f9bc6c57f9118a994d10 (diff)
downloadrust-fac6a646566819bc9daa89de990281420cc1b01f.tar.gz
rust-fac6a646566819bc9daa89de990281420cc1b01f.zip
Auto merge of #12804 - jonas-schievink:config-watcher, r=Veykril
fix: make file watcher config a drop-down (and clarify the options)

Fixes https://github.com/rust-lang/rust-analyzer/issues/12794

Also renames "notify" to "server", since that's clearer ("notify" is still accepted for compatibility).
-rw-r--r--crates/rust-analyzer/src/config.rs29
-rw-r--r--crates/rust-analyzer/src/reload.rs2
-rw-r--r--editors/code/package.json10
3 files changed, 32 insertions, 9 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 87a15432a4f..d498d8fe320 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -213,7 +213,7 @@ config_data! {
         /// also need to add the folders to Code's `files.watcherExclude`.
         files_excludeDirs: Vec<PathBuf> = "[]",
         /// Controls file watching implementation.
-        files_watcher: String = "\"client\"",
+        files_watcher: FilesWatcherDef = "\"client\"",
 
         /// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
         highlightRelated_breakPoints_enable: bool = "true",
@@ -524,7 +524,7 @@ pub struct FilesConfig {
 #[derive(Debug, Clone)]
 pub enum FilesWatcher {
     Client,
-    Notify,
+    Server,
 }
 
 #[derive(Debug, Clone)]
@@ -903,12 +903,11 @@ impl Config {
 
     pub fn files(&self) -> FilesConfig {
         FilesConfig {
-            watcher: match self.data.files_watcher.as_str() {
-                "notify" => FilesWatcher::Notify,
-                "client" if self.did_change_watched_files_dynamic_registration() => {
+            watcher: match self.data.files_watcher {
+                FilesWatcherDef::Client if self.did_change_watched_files_dynamic_registration() => {
                     FilesWatcher::Client
                 }
-                _ => FilesWatcher::Notify,
+                _ => FilesWatcher::Server,
             },
             exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
         }
@@ -1423,7 +1422,7 @@ enum ManifestOrProjectJson {
 
 #[derive(Deserialize, Debug, Clone)]
 #[serde(rename_all = "snake_case")]
-pub enum ExprFillDefaultDef {
+enum ExprFillDefaultDef {
     Todo,
     Default,
 }
@@ -1488,6 +1487,14 @@ enum ReborrowHintsDef {
 
 #[derive(Deserialize, Debug, Clone)]
 #[serde(rename_all = "snake_case")]
+enum FilesWatcherDef {
+    Client,
+    Notify,
+    Server,
+}
+
+#[derive(Deserialize, Debug, Clone)]
+#[serde(rename_all = "snake_case")]
 enum ImportPrefixDef {
     Plain,
     #[serde(alias = "self")]
@@ -1843,6 +1850,14 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
                 "Show only the parameters."
             ],
         },
+        "FilesWatcherDef" => set! {
+            "type": "string",
+            "enum": ["client", "server"],
+            "enumDescriptions": [
+                "Use the client (editor) to watch files for changes",
+                "Use server-side file watching",
+            ],
+        },
         _ => panic!("missing entry for {}: {}", ty, default),
     }
 
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 13bcb7dfa23..77125f88f47 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -320,7 +320,7 @@ impl GlobalState {
 
         let watch = match files_config.watcher {
             FilesWatcher::Client => vec![],
-            FilesWatcher::Notify => project_folders.watch,
+            FilesWatcher::Server => project_folders.watch,
         };
         self.vfs_config_version += 1;
         self.loader.handle.set_config(vfs::loader::Config {
diff --git a/editors/code/package.json b/editors/code/package.json
index 98ea922e4ad..020e3b03318 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -686,7 +686,15 @@
                 "rust-analyzer.files.watcher": {
                     "markdownDescription": "Controls file watching implementation.",
                     "default": "client",
-                    "type": "string"
+                    "type": "string",
+                    "enum": [
+                        "client",
+                        "server"
+                    ],
+                    "enumDescriptions": [
+                        "Use the client (editor) to watch files for changes",
+                        "Use server-side file watching"
+                    ]
                 },
                 "rust-analyzer.highlightRelated.breakPoints.enable": {
                     "markdownDescription": "Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.",