Vim::Helper::Plugin - Base class and API for writing new plugins
This package acts as a base class for all plugins. It also provides an API for writing new plugins quickly and efficiently. When you use Vim::Helper::Plugin it automatically sets itself as a base class on your class.
use Vim::Helper::Plugin
package Vim::Helper::MyPlugin; use strict; use warnings; # Load the plugin base class, and specify our configuration options. # A read/write accessor will be generated for every config option added. # If a default is specified it will be used when no option is provided. # Defaults can be wrapped in a sub if they need ot be generated per # instance. # If required is specified, the program will crash if the config does not # specify the option. use Vim::Helper::Plugin( config_option_foo => { default => 'foo' }, config_option_bar => { default => sub {[ 'bar' ]} }, config_option_baz => { required => 1 }, ); ######################### # Override some methods: # args and opts, each key must be a valid key for the type in Declare::CLI. # An additional key of 'help' is accepted for use in the 'help' command. # Both of these are optional, no need to override them sub args {{ key => %CONFIG }} sub opts {{ key => %CONFIG }} # VIMRC content (if we have any, otherwise do not override) sub vimrc { my $self = shift; my ( $helper, $opts ) = @_; my $cmd = $helper->command( $opts ); ... return $VIMRC_CONTENT; } ######################### # Add our own methods: sub do_something { my $self = shift; ... } 1;
Get the hashref of args provided by this plugin.
Get the hashref of opts provided by this plugin.
Create a new instance.
Generate the vimrc content for this plugin.
You probably should not override this unless you REALLY want to change how your classes configuration function behaves.
For each key it will set the proper accessor. If a required key is omitted an error is thrown. If a key is invalid an error will be thrown.
Chad Granum exodist7@gmail.com
Copyright (C) 2012 Chad Granum
Vim-Helper is free software; Standard perl licence.
Vim-Helper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
To install Vim::Helper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Vim::Helper
CPAN shell
perl -MCPAN -e shell install Vim::Helper
For more information on module installation, please visit the detailed CPAN module installation guide.