Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(find_root): add $ROOT environment variable detection #4363

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion helix-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ pub fn find_first_non_whitespace_char(line: RopeSlice) -> Option<usize> {
/// Find project root.
///
/// Order of detection:
/// * `ROOT` environment variable
/// * Top-most folder containing a root marker in current git repository
/// * Git repository root if no marker detected
/// * Top-most folder containing a root marker if not git repository detected
/// * Current working directory as fallback
pub fn find_root(root: Option<&str>, root_markers: &[String]) -> std::path::PathBuf {
let current_dir = std::env::current_dir().expect("unable to determine current directory");
use std::env;
if let Ok(path) = env::var("ROOT") {
return path.into();
}
let current_dir = env::current_dir().expect("unable to determine current directory");

let root = match root {
Some(root) => {
Expand Down
1 change: 1 addition & 0 deletions helix-lsp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl Client {
doc_path.and_then(|x| x.parent().and_then(|x| x.to_str())),
root_markers,
);
log::info!("root_path: {root_path:?}");

let root_uri = lsp::Url::from_file_path(root_path.clone()).ok();

Expand Down