mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
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).
This commit is contained in:
commit
fac6a64656
@ -213,7 +213,7 @@ config_data! {
|
|||||||
/// also need to add the folders to Code's `files.watcherExclude`.
|
/// also need to add the folders to Code's `files.watcherExclude`.
|
||||||
files_excludeDirs: Vec<PathBuf> = "[]",
|
files_excludeDirs: Vec<PathBuf> = "[]",
|
||||||
/// Controls file watching implementation.
|
/// 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.
|
/// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
|
||||||
highlightRelated_breakPoints_enable: bool = "true",
|
highlightRelated_breakPoints_enable: bool = "true",
|
||||||
@ -524,7 +524,7 @@ pub struct FilesConfig {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum FilesWatcher {
|
pub enum FilesWatcher {
|
||||||
Client,
|
Client,
|
||||||
Notify,
|
Server,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -903,12 +903,11 @@ impl Config {
|
|||||||
|
|
||||||
pub fn files(&self) -> FilesConfig {
|
pub fn files(&self) -> FilesConfig {
|
||||||
FilesConfig {
|
FilesConfig {
|
||||||
watcher: match self.data.files_watcher.as_str() {
|
watcher: match self.data.files_watcher {
|
||||||
"notify" => FilesWatcher::Notify,
|
FilesWatcherDef::Client if self.did_change_watched_files_dynamic_registration() => {
|
||||||
"client" if self.did_change_watched_files_dynamic_registration() => {
|
|
||||||
FilesWatcher::Client
|
FilesWatcher::Client
|
||||||
}
|
}
|
||||||
_ => FilesWatcher::Notify,
|
_ => FilesWatcher::Server,
|
||||||
},
|
},
|
||||||
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
|
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
|
||||||
}
|
}
|
||||||
@ -1423,7 +1422,7 @@ enum ManifestOrProjectJson {
|
|||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ExprFillDefaultDef {
|
enum ExprFillDefaultDef {
|
||||||
Todo,
|
Todo,
|
||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
@ -1486,6 +1485,14 @@ enum ReborrowHintsDef {
|
|||||||
Mutable,
|
Mutable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
enum FilesWatcherDef {
|
||||||
|
Client,
|
||||||
|
Notify,
|
||||||
|
Server,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
enum ImportPrefixDef {
|
enum ImportPrefixDef {
|
||||||
@ -1843,6 +1850,14 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
|||||||
"Show only the parameters."
|
"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),
|
_ => panic!("missing entry for {}: {}", ty, default),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ impl GlobalState {
|
|||||||
|
|
||||||
let watch = match files_config.watcher {
|
let watch = match files_config.watcher {
|
||||||
FilesWatcher::Client => vec![],
|
FilesWatcher::Client => vec![],
|
||||||
FilesWatcher::Notify => project_folders.watch,
|
FilesWatcher::Server => project_folders.watch,
|
||||||
};
|
};
|
||||||
self.vfs_config_version += 1;
|
self.vfs_config_version += 1;
|
||||||
self.loader.handle.set_config(vfs::loader::Config {
|
self.loader.handle.set_config(vfs::loader::Config {
|
||||||
|
@ -686,7 +686,15 @@
|
|||||||
"rust-analyzer.files.watcher": {
|
"rust-analyzer.files.watcher": {
|
||||||
"markdownDescription": "Controls file watching implementation.",
|
"markdownDescription": "Controls file watching implementation.",
|
||||||
"default": "client",
|
"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": {
|
"rust-analyzer.highlightRelated.breakPoints.enable": {
|
||||||
"markdownDescription": "Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.",
|
"markdownDescription": "Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.",
|
||||||
|
Loading…
Reference in New Issue
Block a user