Commit 8217eac3 authored by Derek Stavis's avatar Derek Stavis

themes: supercharge require to also load themes

parent f79cd118
...@@ -15,12 +15,14 @@ set -l theme_function_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme{,/functions} ...@@ -15,12 +15,14 @@ set -l theme_function_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme{,/functions}
# Autoload core library # Autoload core library
set fish_function_path $fish_function_path[1] \ set fish_function_path $fish_function_path[1] \
$core_function_path \ $core_function_path \
$theme_function_path \
$fish_function_path[2..-1] $fish_function_path[2..-1]
# Require all packages # Require all packages
emit perf:timer:start "Oh My Fish init installed packages" emit perf:timer:start "Oh My Fish init installed packages"
require --path {$OMF_PATH,$OMF_CONFIG}/pkg/* require --path {$OMF_PATH,$OMF_CONFIG}/pkg/*
emit perf:timer:finish "Oh My Fish init installed packages" emit perf:timer:finish "Oh My Fish init installed packages"
emit perf:timer:start "Oh My Fish init selected theme"
require --theme $theme
emit perf:timer:finish "Oh My Fish init selected theme"
# Backup key bindings # Backup key bindings
functions -q fish_user_key_bindings functions -q fish_user_key_bindings
and functions -c fish_user_key_bindings __original_fish_user_key_bindings and functions -c fish_user_key_bindings __original_fish_user_key_bindings
......
...@@ -8,29 +8,35 @@ function require ...@@ -8,29 +8,35 @@ function require
return 1 return 1
end end
# If bundle should be # If bundle should not be processed
if set index (contains -i -- --no-bundle $packages) if set index (contains -i -- --no-bundle $packages)
set -e packages[$index] set -e packages[$index]
set ignore_bundle set ignore_bundle
end end
# If requiring a theme we load the root path
if set index (contains -i -- --theme $packages)
set -e packages[$index]
set package_path {$OMF_PATH,$OMF_CONFIG}/theme?/$packages
set function_path $package_path
else
set package_path {$OMF_PATH,$OMF_CONFIG}/pk?/$packages
end
# Requiring absolute paths # Requiring absolute paths
if set index (contains -i -- --path $packages) if set index (contains -i -- --path $packages)
set -e packages[$index] set -e packages[$index]
set package_path $packages set package_path $packages
# Requiring specific packages from default paths
else
set package_path {$OMF_PATH,$OMF_CONFIG}/pkg*/$packages
# Exit with error if no package paths were generated
test -z "$package_path"
and return 1
end end
set function_path $package_path/functions* # Exit with error if no paths were generated
set complete_path $package_path/completions* test -z "$package_path"
set init_path $package_path/init.fish* and return 1
# Build package paths
set function_path $function_path $package_path/function?
set complete_path $package_path/completion?
set init_path $package_path/ini?.fish
# Autoload functions # Autoload functions
test -n "$function_path" test -n "$function_path"
......
...@@ -19,9 +19,12 @@ function omf.theme.set -a target_theme ...@@ -19,9 +19,12 @@ function omf.theme.set -a target_theme
return $OMF_INVALID_ARG return $OMF_INVALID_ARG
end end
# Replace autoload paths of current theme with the target one # Remove current theme paths
autoload -e {$OMF_CONFIG,$OMF_PATH}/themes/$current_theme set -l current_theme_paths {$OMF_CONFIG,$OMF_PATH}/theme?/{,functions,completions}/$current_theme
autoload {$OMF_CONFIG,$OMF_PATH}/themes/$target_theme autoload -e $current_theme_paths
# Require new theme
require --theme $target_theme
# Find target theme's fish_prompt and link to user function path # Find target theme's fish_prompt and link to user function path
for path in {$OMF_CONFIG,$OMF_PATH}/themes/$target_theme/$prompt_filename for path in {$OMF_CONFIG,$OMF_PATH}/themes/$target_theme/$prompt_filename
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment