Attached is my version of a plugin-manager.  It has what I consider nice 
features:

First, a plugin can get rid of all the checking code and just do something like 
this at the beginning:

    PlugCanLoad my-excellent-plugin 700

That checks to see if 'my-excellent-plugin' has been loaded.  If it has, 
nothing more happens.  If it hasn't, and the vim version is at least 700, the 
plugin will continue loading (and the manager will track that it has been 
loaded).

Someone desiring to inhibit the loading of the plugin can call:

    PlugSetLoaded my-excellent-plugin 1

so the manager will not let the plugin load.  This can be used either to 
inhibit the loading initially, or to reset it so one can reload a plugin.

Inside the plugin, one can add to a global "Plugin" menu by doing:

    call PlugAddMenu('Excellent', 'Make this excellent', ":call 
DoSomethingExcellent()<cr>")

This will make a menu "Plugin.Excellent.Make\ this\ excellent".

The advantage of such a scheme is that all plugins can put menus in a uniform 
location without conflicting (well, the topic names need to be unique...)

There is also

    call PlugAddSep('Excellent')

which autogenerates a unique separator id for that menu.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


*0000_Plugin.txt*  Manage plugins      

Author:  Ron Aaron <[email protected]>
License: Same terms as Vim itself (see |license|)

Control plugins simply.

=============================================================================

                                                                  *PlugCanLoad*

Used by a plugin to determine whether or not it should load:

   PlugCanLoad <plugname> <vimver>

<plugname> is the name identifying the specific plugin.  It must be unique
among all the plugins.  It can be any identifier (no whitespace).

<vimver> is the minimal version of Vim which the plugin requires.

If the plugin has already been loaded, has been suppressed or if the Vim
version is too low, the plugin will not be loaded.

=============================================================================

                                                                *PlugSetLoaded*

Tells the manager that the plugin is loaded (or unloaded).  This is useful if
put in a e.g. 0000_Pluginhibit.vim plugin, to prevent the loading of unwanted
plugins (maybe temporarily).  It can also be used to "reset" the manager's
idea of whether a plugin is loaded, so it may be reloaded.


   PlugSetLoaded <plugname> <loaded>

<plugname> must match the plugin's identifier, and "loaded" is 0 or 1

=============================================================================

                                                                  *PlugAddMenu*

Function which adds an item to the "Plugin" menu:

        PlugAddMenu( topic, value, cmd )

"topic" is the menu item under "Plugin" where the item will be found.
"value" is the menu item text and "cmd" is the command the menu should
execute.  For example:

        PlugAddMenu("&MyPlugin", "Something wild", ":call MyWildThing()<cr>")

That will make a "Plugin.MyPlugin" menu, with a "Something wild" entry which
when activated executes ":call MyWildThing()<cr>"

=============================================================================

                                                                   *PlugAddSep*

This adds an automatically-unique separator to the menu:

        PlugAddSep( topic )

 vim:tw=78:et:ft=help:norl:

Attachment: 0000_Plugin.vim
Description: Binary data

Raspunde prin e-mail lui