diff --git a/NEWS b/NEWS index 334fea70..74f6380f 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ special versions for the old behavior * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and VimperatorLeave respectively + * add :loadplugins command * add . mapping * add N% normal mode command * add interpolation for items such as to autocommands diff --git a/content/liberator.js b/content/liberator.js index 62e60106..a0773ed4 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -331,6 +331,10 @@ const liberator = (function () //{{{ hereDoc: true, }); + liberator.commands.add(["loadplugins", "lpl"], + "Load all plugins immediately", + function () { liberator.loadPlugins(); }); + liberator.commands.add(["norm[al]"], "Execute Normal mode commands", function (args, special) { liberator.events.feedkeys(args.string, special); }, @@ -891,6 +895,49 @@ const liberator = (function () //{{{ loadModule: function (name, func) { loadModule(name, func); }, + loadPlugins: function () + { + // FIXME: largely duplicated for loading macros + try + { + let dirs = liberator.io.getRuntimeDirectories("plugin"); + + if (dirs.length > 0) + { + for (let [,dir] in Iterator(dirs)) + { + // TODO: search plugins/**/* for plugins + liberator.echomsg("Searching for \"plugin/*.{js,vimp}\" in \"" + dir.path + "\"", 2); + + liberator.log("Sourcing plugin directory: " + dir.path + "...", 3); + + let files = liberator.io.readDirectory(dir.path, true); + + files.forEach(function (file) { + if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path)) + { + try + { + liberator.io.source(file.path, false); + liberator.pluginFiles[file.path] = true; + } + catch (e) {}; + } + }); + } + } + else + { + liberator.log("No user plugin directory found", 3); + } + } + catch (e) + { + // thrown if directory does not exist + liberator.log("Error sourcing plugin directory: " + e, 9); + } + }, + // logs a message to the javascript error console // if msg is an object, it is beautified // TODO: add proper level constants @@ -1001,6 +1048,8 @@ const liberator = (function () //{{{ // v.plugins.onEvent = function triggered, on keypresses (unless ) (see events.js) plugins: {}, + pluginFiles: {}, + // quit liberator, no matter how many tabs/windows are open quit: function (saveSession, force) { @@ -1110,40 +1159,7 @@ const liberator = (function () //{{{ liberator.log("No user RC file found", 3); if (liberator.options["loadplugins"]) - { - // FIXME: largely duplicated for loading macros - try - { - let dirs = liberator.io.getRuntimeDirectories("plugin"); - - if (dirs.length > 0) - { - for (let [,dir] in Iterator(dirs)) - { - // TODO: search plugins/**/* for plugins - liberator.echomsg("Searching for \"plugin/*.{js,vimp}\" in \"" + dir.path + "\"", 2); - - liberator.log("Sourcing plugin directory: " + dir.path + "...", 3); - - let files = liberator.io.readDirectory(dir.path, true); - - files.forEach(function (file) { - if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path)) - liberator.io.source(file.path, false); - }); - } - } - else - { - liberator.log("No user plugin directory found", 3); - } - } - catch (e) - { - // thrown if directory does not exist - liberator.log("Error sourcing plugin directory: " + e, 9); - } - } + liberator.loadPlugins; // after sourcing the initialization files, this function will set // all gui options to their default values, if they have not been diff --git a/content/ui.js b/content/ui.js index 19997b66..3148a957 100644 --- a/content/ui.js +++ b/content/ui.js @@ -1369,7 +1369,7 @@ liberator.ItemList = function (id) //{{{ { minHeight = 0; autoSize(); - fill(startIndex); + setTimeout(function () { fill(startIndex); }, 0); } container.collapsed = false; }, diff --git a/locale/en-US/index.txt b/locale/en-US/index.txt index e4e33090..8c0cd586 100644 --- a/locale/en-US/index.txt +++ b/locale/en-US/index.txt @@ -186,6 +186,7 @@ section:Ex{nbsp}commands[ex-cmd-index,:index] ||:javascript|| Run a JavaScript command through eval() + ||:jumps|| Show jumplist + ||:let|| Set or list a variable + +||:loadplugins|| Immediately load all unloaded plugins + ||:macros|| List all macros + ||:map|| Map a key sequence + ||:mapclear|| Remove all mappings + diff --git a/locale/en-US/repeat.txt b/locale/en-US/repeat.txt index 6f19c0ea..b2e81f3c 100644 --- a/locale/en-US/repeat.txt +++ b/locale/en-US/repeat.txt @@ -92,6 +92,15 @@ printed. ________________________________________________________________________________ +|:lpl| |:loadplugins| +||:loadplugins|| + +________________________________________________________________________________ +Load all unloaded plugins immediately. This is useful both for sourcing new +plugins without restarting vimperator, and making sure that a plugin is loaded +so that you can use its commands from your vimperatorrc. +________________________________________________________________________________ + + |:ru| |:runtime| ||:ru[ntime][!]| {file} ...|| + ________________________________________________________________________________