pub struct ThemeLoader { /* private fields */ }Expand description
Discovers and loads Helix-compatible theme files from one or more directories.
let loader = ThemeLoader::new(["/home/me/.config/helix/themes"]);
let theme = loader.load("catppuccin_mocha")?;
let style = theme.get("ui.text");Implementations§
Source§impl ThemeLoader
impl ThemeLoader
Sourcepub fn new<I, P>(theme_dirs: I) -> Self
pub fn new<I, P>(theme_dirs: I) -> Self
Create a loader that searches theme_dirs for .toml theme files.
Directories are searched in order; first match wins.
Sourcepub fn default_search_paths(app_theme_dir: impl Into<PathBuf>) -> Self
pub fn default_search_paths(app_theme_dir: impl Into<PathBuf>) -> Self
Create a loader with app-local themes first, then standard Helix user
config themes ($XDG_CONFIG_HOME/helix/themes or
$HOME/.config/helix/themes).
Sourcepub fn load(&self, name: &str) -> Result<Theme, ThemeError>
pub fn load(&self, name: &str) -> Result<Theme, ThemeError>
Load a theme by name (stem without .toml extension).
Sourcepub fn load_ref(&self, theme_ref: &str) -> Result<Theme, ThemeError>
pub fn load_ref(&self, theme_ref: &str) -> Result<Theme, ThemeError>
Load a theme by name or explicit file path.
Names like "catppuccin_mocha" are searched as <dir>/<name>.toml.
Single-component filenames like "catppuccin_mocha.toml" are searched
directly in each configured directory. Absolute paths and relative paths
with separators are loaded as file paths.
Sourcepub fn load_path(&self, path: impl AsRef<Path>) -> Result<Theme, ThemeError>
pub fn load_path(&self, path: impl AsRef<Path>) -> Result<Theme, ThemeError>
Load a theme from an explicit file path.
Sourcepub fn read_names(&self) -> Vec<String>
pub fn read_names(&self) -> Vec<String>
List all available theme names (sorted, deduplicated stems).
Trait Implementations§
Source§impl Clone for ThemeLoader
impl Clone for ThemeLoader
Source§fn clone(&self) -> ThemeLoader
fn clone(&self) -> ThemeLoader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ThemeLoader
impl RefUnwindSafe for ThemeLoader
impl Send for ThemeLoader
impl Sync for ThemeLoader
impl Unpin for ThemeLoader
impl UnsafeUnpin for ThemeLoader
impl UnwindSafe for ThemeLoader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more