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

Optionally load init.scm and helix.scm from .helix/ #6

Merged
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
19 changes: 16 additions & 3 deletions helix-term/src/commands/engine/steel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use arc_swap::ArcSwapAny;
use helix_core::{
diagnostic::Severity,
extensions::steel_implementations::{rope_module, SteelRopeSlice},
graphemes,
find_workspace, graphemes,
shellwords::Shellwords,
syntax::{AutoPairConfig, SoftWrap},
Range, Selection, Tendril,
Expand Down Expand Up @@ -1198,12 +1198,25 @@ pub fn is_keymap(keymap: SteelVal) -> bool {
}
}

fn local_config_exists() -> bool {
let local_helix = find_workspace().0.join(".helix");
local_helix.join("helix.scm").exists() && local_helix.join("init.scm").exists()
}

fn preferred_config_path(file_name: &str) -> PathBuf {
if local_config_exists() {
find_workspace().0.join(".helix").join(file_name)
} else {
helix_loader::config_dir().join(file_name)
}
}

pub fn helix_module_file() -> PathBuf {
helix_loader::config_dir().join("helix.scm")
preferred_config_path("helix.scm")
}

pub fn steel_init_file() -> PathBuf {
helix_loader::config_dir().join("init.scm")
preferred_config_path("init.scm")
}

#[derive(Clone)]
Expand Down