aboutsummaryrefslogtreecommitdiff
path: root/helix-loader/src/lib.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-02-07 14:59:04 +0000
committerBlaž Hrastnik2023-03-29 03:57:30 +0000
commit5b3dd6a678ba138ea21d7d5dd8d3c8a53c7a6d3b (patch)
tree038502a6e1d4f7b4a90ac407f3debf00ede211c1 /helix-loader/src/lib.rs
parent2d10a429ebf7abe5af184b6227346377dc0523e8 (diff)
implement proper lsp-workspace support
fix typo Co-authored-by: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com>
Diffstat (limited to 'helix-loader/src/lib.rs')
-rw-r--r--helix-loader/src/lib.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs
index 51bde716..6c716975 100644
--- a/helix-loader/src/lib.rs
+++ b/helix-loader/src/lib.rs
@@ -129,7 +129,7 @@ pub fn config_file() -> PathBuf {
}
pub fn workspace_config_file() -> PathBuf {
- find_workspace().join(".helix").join("config.toml")
+ find_workspace().0.join(".helix").join("config.toml")
}
pub fn lang_config_file() -> PathBuf {
@@ -283,14 +283,19 @@ mod merge_toml_tests {
}
/// Finds the current workspace folder.
-/// Used as a ceiling dir for root resolve, for the filepicker and other related
-pub fn find_workspace() -> PathBuf {
+/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
+///
+/// This function starts searching the FS upward from the CWD
+/// and returns the first directory that contains either `.git` or `.helix`.
+/// If no workspace was found returns (CWD, true).
+/// Otherwise (workspace, false) is returned
+pub fn find_workspace() -> (PathBuf, bool) {
let current_dir = std::env::current_dir().expect("unable to determine current directory");
for ancestor in current_dir.ancestors() {
if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
- return ancestor.to_owned();
+ return (ancestor.to_owned(), false);
}
}
- current_dir
+ (current_dir, true)
}