From bc4e54c0c45abbbb5fe9ac3278361d0b4e5774ba Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 7 Apr 2021 23:56:20 +0900 Subject: Load config files from ~/.config/helix, fallback to defaults. --- helix-core/Cargo.toml | 2 ++ helix-core/src/lib.rs | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'helix-core') diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index d95c0f47..4b1566d7 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -21,3 +21,5 @@ once_cell = "1.4" regex = "1" serde = { version = "1.0", features = ["derive"] } + +xdg = "2.0" diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs index b3ce3c47..dda9863b 100644 --- a/helix-core/src/lib.rs +++ b/helix-core/src/lib.rs @@ -44,6 +44,13 @@ pub(crate) fn find_first_non_whitespace_char(text: RopeSlice, line_num: usize) - None } +pub fn config_dir() -> std::path::PathBuf { + // TODO: allow env var override + let xdg_dirs = + xdg::BaseDirectories::with_prefix("helix").expect("Unable to find XDG directories!"); + xdg_dirs.get_config_home() +} + pub use ropey::{Rope, RopeSlice}; pub use tendril::StrTendril as Tendril; -- cgit v1.2.3-70-g09d2