2015-09-26 23:15:18 +00:00
|
|
|
# SYNOPSIS
|
|
|
|
# require [name]
|
|
|
|
#
|
|
|
|
# OVERVIEW
|
|
|
|
# Require a plugin:
|
|
|
|
# - Autoload its functions and completions.
|
2015-11-02 00:03:56 +00:00
|
|
|
# - Require bundle dependencies.
|
2015-09-26 23:15:18 +00:00
|
|
|
# - Source its initialization file.
|
|
|
|
# - Emit its initialization event.
|
|
|
|
#
|
|
|
|
# If the required plugin has already been loaded, does nothing.
|
|
|
|
|
|
|
|
function require -a name
|
|
|
|
# Skip if plugin has already been loaded.
|
|
|
|
contains -- $OMF_PATH/pkg/$name $fish_function_path;
|
|
|
|
or contains -- $OMF_CONFIG/pkg/$name $fish_function_path;
|
|
|
|
and return 0
|
|
|
|
|
|
|
|
for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$name
|
2015-11-02 00:03:56 +00:00
|
|
|
test -d $path; or continue
|
|
|
|
|
2015-10-03 21:15:40 +00:00
|
|
|
if autoload $path $path/functions $path/completions
|
2015-09-26 23:15:18 +00:00
|
|
|
|
2015-11-02 00:03:56 +00:00
|
|
|
if test -f $path/bundle
|
|
|
|
for line in (cat $path/bundle)
|
|
|
|
test (echo $line | cut -d' ' -f1) = package;
|
|
|
|
and set dependency (basename (echo $line | cut -d' ' -f2));
|
|
|
|
and require $dependency
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-26 23:15:18 +00:00
|
|
|
source $path/init.fish ^/dev/null;
|
|
|
|
or source $path/$name.fish ^/dev/null;
|
|
|
|
and emit init_$name $path
|
|
|
|
end
|
|
|
|
end
|
2015-10-15 00:49:12 +00:00
|
|
|
|
|
|
|
functions -e init # Cleanup previously sourced function
|
|
|
|
|
|
|
|
return 0
|
2015-09-26 23:15:18 +00:00
|
|
|
end
|