mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 10:56:19 +04:00
Determine runtime dir based on executable location or env override.
This commit is contained in:
parent
d33e8fd3d8
commit
0f77f543e5
@ -44,6 +44,18 @@ pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -
|
||||
None
|
||||
}
|
||||
|
||||
pub fn runtime_dir() -> std::path::PathBuf {
|
||||
// runtime env var || dir where binary is located
|
||||
std::env::var("HELIX_RUNTIME")
|
||||
.map(|path| path.into())
|
||||
.unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|path| path.parent().map(|path| path.to_path_buf()))
|
||||
.unwrap()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn config_dir() -> std::path::PathBuf {
|
||||
// TODO: allow env var override
|
||||
let xdg_dirs =
|
||||
|
@ -63,7 +63,8 @@ fn read_query(language: &str, filename: &str) -> String {
|
||||
static INHERITS_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r";+\s*inherits\s*:?\s*([a-z_,()]+)\s*").unwrap());
|
||||
|
||||
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let root = crate::runtime_dir();
|
||||
// let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
let path = root
|
||||
.join("../runtime/queries")
|
||||
|
Loading…
Reference in New Issue
Block a user