on master help sign in
Determine runtime dir based on executable location or env override.
0f77f54Blaž Hrastnik
helix-core/src/lib.rs+12
@@ -44,6 +44,18 @@ pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -
44 None
44 None
45}
45}
46
46
47+pub fn runtime_dir() -> std::path::PathBuf {
48+ // runtime env var || dir where binary is located
49+ std::env::var("HELIX_RUNTIME")
50+ .map(|path| path.into())
51+ .unwrap_or_else(|_| {
52+ std::env::current_exe()
53+ .ok()
54+ .and_then(|path| path.parent().map(|path| path.to_path_buf()))
55+ .unwrap()
56+ })
57+}
58+
47pub fn config_dir() -> std::path::PathBuf {
59pub fn config_dir() -> std::path::PathBuf {
48 // TODO: allow env var override
60 // TODO: allow env var override
49 let xdg_dirs =
61 let xdg_dirs =
helix-core/src/syntax.rs+2−1
@@ -63,7 +63,8 @@ fn read_query(language: &str, filename: &str) -> String {
63 static INHERITS_REGEX: Lazy<Regex> =
63 static INHERITS_REGEX: Lazy<Regex> =
64 Lazy::new(|| Regex::new(r";+\s*inherits\s*:?\s*([a-z_,()]+)\s*").unwrap());
64 Lazy::new(|| Regex::new(r";+\s*inherits\s*:?\s*([a-z_,()]+)\s*").unwrap());
65
65
66+ let root = crate::runtime_dir();
66− let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
67+ // let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
67
68
68 let path = root
69 let path = root
69 .join("../runtime/queries")
70 .join("../runtime/queries")
shell.nix+2
@@ -11,5 +11,7 @@ pkgs.mkShell {
11 RUST_BACKTRACE = "1";
11 RUST_BACKTRACE = "1";
12 # https://github.com/rust-lang/rust/issues/55979
12 # https://github.com/rust-lang/rust/issues/55979
13 LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
13 LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
14+
15+ HELIX_RUNTIME=./runtime;
14}
16}
15
17