mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 00:37:58 +01:00
Search recursively for plugins in liberator.loadPlugins.
This commit is contained in:
@@ -588,7 +588,6 @@ function Events() //{{{
|
|||||||
// load all macros inside ~/.vimperator/macros/
|
// load all macros inside ~/.vimperator/macros/
|
||||||
// setTimeout needed since io. is loaded after events.
|
// setTimeout needed since io. is loaded after events.
|
||||||
setTimeout (function () {
|
setTimeout (function () {
|
||||||
// FIXME: largely duplicated for loading plugins
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
let dirs = io.getRuntimeDirectories("macros");
|
let dirs = io.getRuntimeDirectories("macros");
|
||||||
|
|||||||
@@ -988,27 +988,17 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
loadPlugins: function ()
|
loadPlugins: function ()
|
||||||
{
|
{
|
||||||
// FIXME: largely duplicated for loading macros
|
function sourceDirectory(dir)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
let dirs = io.getRuntimeDirectories("plugin");
|
if (!dir.isReadable())
|
||||||
|
|
||||||
if (dirs.length == 0)
|
|
||||||
{
|
{
|
||||||
liberator.log("No user plugin directory found", 3);
|
liberator.echoerr("E484: Can't open file " + dir.path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let [,dir] in Iterator(dirs))
|
|
||||||
{
|
|
||||||
// TODO: search plugins/**/* for plugins
|
|
||||||
liberator.echomsg('Searching for "plugin/*.{js,vimp}" in ' + dir.path.quote(), 2);
|
|
||||||
|
|
||||||
liberator.log("Sourcing plugin directory: " + dir.path + "...", 3);
|
liberator.log("Sourcing plugin directory: " + dir.path + "...", 3);
|
||||||
|
io.readDirectory(dir.path, true).forEach(function (file) {
|
||||||
let files = io.readDirectory(dir.path, true);
|
if (file.isFile() && /\.(js|vimp)$/i.test(file.path) && !(file.path in liberator.pluginFiles))
|
||||||
|
|
||||||
files.forEach(function (file) {
|
|
||||||
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path) && !(file.path in liberator.pluginFiles))
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1020,14 +1010,28 @@ const liberator = (function () //{{{
|
|||||||
liberator.reportError(e);
|
liberator.reportError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (file.isDirectory())
|
||||||
|
{
|
||||||
|
sourceDirectory(file);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (e)
|
let dirs = io.getRuntimeDirectories("plugin");
|
||||||
|
|
||||||
|
if (dirs.length == 0)
|
||||||
{
|
{
|
||||||
// thrown if directory does not exist
|
liberator.log("No user plugin directory found", 3);
|
||||||
liberator.log("Error sourcing plugin directory: " + e, 9);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
liberator.echomsg('Searching for "plugin/**/*.{js,vimp}" in '
|
||||||
|
+ [dir.path.replace(/.plugin$/, "") for each (dir in dirs)].join(",").quote(), 2);
|
||||||
|
|
||||||
|
dirs.forEach(function (dir) {
|
||||||
|
liberator.echomsg("Searching for " + (dir.path + "/**/*.{js,vimp}").quote(), 3);
|
||||||
|
sourceDirectory(dir);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// logs a message to the javascript error console
|
// logs a message to the javascript error console
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ If 'exrc' is set then any RC file in the current directory is also sourced.
|
|||||||
|
|
||||||
The plugin directory can be in any of the directories in 'runtimepath'.
|
The plugin directory can be in any of the directories in 'runtimepath'.
|
||||||
|
|
||||||
All directories in 'runtimepath' are searched for plugins and they are are all
|
All directories in 'runtimepath' are searched for a "plugin" subdirectory and
|
||||||
loaded.
|
all are loaded. For each plugin directory all *.\{js,vimp} files (including
|
||||||
|
those in further subdirectories) are sourced alphabetically.
|
||||||
|
|
||||||
Plugins will not be sourced if 'noloadplugins' is set.
|
Plugins will not be sourced if 'noloadplugins' is set.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user