on master help sign in
Determine runtime dir based on executable location or env override.
commit0f77f543e5a7a6be0eabd2d4b72591cdafc7ec71 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 10 May 2021, 01:02 (5 years ago) parentd33e8fd
3 files changed+16−1
helix-core/src/lib.rs+12 helix-core/src/syntax.rs+2−1 shell.nix+2
helix-core/src/lib.rs+12
@@ -44,6 +44,18 @@ pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) -
4444 None
4545}
4646
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+
4759pub fn config_dir() -> std::path::PathBuf {
4860 // TODO: allow env var override
4961 let xdg_dirs =
helix-core/src/syntax.rs+2−1
@@ -63,7 +63,8 @@ fn read_query(language: &str, filename: &str) -> String {
6363 static INHERITS_REGEX: Lazy<Regex> =
6464 Lazy::new(|| Regex::new(r";+\s*inherits\s*:?\s*([a-z_,()]+)\s*").unwrap());
6565
66− let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
66+ let root = crate::runtime_dir();
67+ // let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
6768
6869 let path = root
6970 .join("../runtime/queries")
shell.nix+2
@@ -11,5 +11,7 @@ pkgs.mkShell {
1111 RUST_BACKTRACE = "1";
1212 # https://github.com/rust-lang/rust/issues/55979
1313 LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
14+
15+ HELIX_RUNTIME=./runtime;
1416}
1517