aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/health.rs
diff options
context:
space:
mode:
authorpaul-scott2023-03-09 14:50:43 +0000
committerGitHub2023-03-09 14:50:43 +0000
commitce1fb9e64c189fb7476b4c72c6774a5bf6cbfd0f (patch)
tree94b45afe9038ef6b6a45ebf8295223b10ad8fe52 /helix-term/src/health.rs
parent2cf4ce235662fcb272c684751b844b2ebc1b757f (diff)
Generalised to multiple runtime directories with priorities (#5411)
* Generalised to multiple runtime directories with priorities This is an implementation for #3346. Previously, one of the following runtime directories were used: 1. `$HELIX_RUNTIME` 2. sibling directory to `$CARGO_MANIFEST_DIR` 3. subdirectory of user config directory 4. subdirectory of path to helix executable The first directory provided / found to exist in this order was used as a root for all runtime file searches (grammars, themes, queries). This change lowers the priority of `$HELIX_RUNTIME` so that the user config runtime has higher priority. More significantly, all of these directories are now searched for runtime files, enabling a user to override default or system-level runtime files. If the same file name appears in multiple runtime directories, the following priority is now used: 1. sibling directory to `$CARGO_MANIFEST_DIR` 2. subdirectory of user config directory 3. `$HELIX_RUNTIME` 4. subdirectory of path to helix executable One exception to this rule is that a user can have a `themes` directory directly in the user config directory that has higher piority to `themes` directories in runtime directories. That behaviour has been preserved. As part of implementing this feature `theme::Loader` was simplified and the cycle detection logic of the theme inheritance was improved to cover more cases and to be more explicit. * Removed AsRef usage to avoid binary growth * Health displaying ;-separated runtime dirs * Changed HELIX_RUNTIME build from src instructions * Updated doc for more detail on runtime directories * Improved health symlink printing and theme cycle errors The health display of runtime symlinks now prints both ends of the link. Separate errors are given when theme file is not found and when the only theme file found would form an inheritence cycle. * Satisfied clippy on passing Path * Clarified highest priority runtime directory purpose * Further clarified multiple runtime details in book Also gave markdown headings to subsections. Fixed a error with table indentation not building table that also appears present on master. --------- Co-authored-by: Paul Scott <paul.scott@anu.edu.au> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'helix-term/src/health.rs')
-rw-r--r--helix-term/src/health.rs38
1 files changed, 26 insertions, 12 deletions
diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs
index 6558fe19..480c2c67 100644
--- a/helix-term/src/health.rs
+++ b/helix-term/src/health.rs
@@ -52,7 +52,7 @@ pub fn general() -> std::io::Result<()> {
let config_file = helix_loader::config_file();
let lang_file = helix_loader::lang_config_file();
let log_file = helix_loader::log_file();
- let rt_dir = helix_loader::runtime_dir();
+ let rt_dirs = helix_loader::runtime_dirs();
let clipboard_provider = get_clipboard_provider();
if config_file.exists() {
@@ -66,17 +66,31 @@ pub fn general() -> std::io::Result<()> {
writeln!(stdout, "Language file: default")?;
}
writeln!(stdout, "Log file: {}", log_file.display())?;
- writeln!(stdout, "Runtime directory: {}", rt_dir.display())?;
-
- if let Ok(path) = std::fs::read_link(&rt_dir) {
- let msg = format!("Runtime directory is symlinked to {}", path.display());
- writeln!(stdout, "{}", msg.yellow())?;
- }
- if !rt_dir.exists() {
- writeln!(stdout, "{}", "Runtime directory does not exist.".red())?;
- }
- if rt_dir.read_dir().ok().map(|it| it.count()) == Some(0) {
- writeln!(stdout, "{}", "Runtime directory is empty.".red())?;
+ writeln!(
+ stdout,
+ "Runtime directories: {}",
+ rt_dirs
+ .iter()
+ .map(|d| d.to_string_lossy())
+ .collect::<Vec<_>>()
+ .join(";")
+ )?;
+ for rt_dir in rt_dirs.iter() {
+ if let Ok(path) = std::fs::read_link(rt_dir) {
+ let msg = format!(
+ "Runtime directory {} is symlinked to: {}",
+ rt_dir.display(),
+ path.display()
+ );
+ writeln!(stdout, "{}", msg.yellow())?;
+ }
+ if !rt_dir.exists() {
+ let msg = format!("Runtime directory does not exist: {}", rt_dir.display());
+ writeln!(stdout, "{}", msg.yellow())?;
+ } else if rt_dir.read_dir().ok().map(|it| it.count()) == Some(0) {
+ let msg = format!("Runtime directory is empty: {}", rt_dir.display());
+ writeln!(stdout, "{}", msg.yellow())?;
+ }
}
writeln!(stdout, "Clipboard provider: {}", clipboard_provider.name())?;