summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2022-01-17 20:10:17 -0500
committerGitHub <noreply@github.com>2022-01-17 20:10:17 -0500
commit39ea4abff4bfa09c4e98e00ad0d4e0e7b78f1187 (patch)
tree501ac70cd048f0a197f2accf1cf01234d54cf143 /cli/lsp/language_server.rs
parentb10563cb2083f7af9d4320662d6aa1897b6db23e (diff)
feat: auto-discover config file (#13313)
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 5b04b8a25..fc0ae1312 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -320,7 +320,23 @@ impl Inner {
}
}
- Ok(None)
+ // Auto-discover config
+
+ // It is possible that root_uri is not set, for example when having a single
+ // file open and not a workspace. In those situations we can't
+ // automatically discover the configuration
+ if let Some(root_uri) = maybe_root_uri {
+ let root_path = root_uri.to_file_path().unwrap();
+ let mut checked = std::collections::HashSet::new();
+ let maybe_config =
+ crate::config_file::discover_from(&root_path, &mut checked)?;
+ Ok(maybe_config.map(|c| {
+ lsp_log!(" Auto-resolved configuration file: \"{}\"", c.specifier);
+ c
+ }))
+ } else {
+ Ok(None)
+ }
}
fn is_diagnosable(&self, specifier: &ModuleSpecifier) -> bool {