Skip to content

External vital modules

mityu edited this page Mar 4, 2024 · 17 revisions

The following external vital modules are also available. Feel free to edit this page to share your external vital module.

How to use external vital module

Install an external vital module (e.g. vital-ArgumentParser), using neobundle.vim or other vim plugin managers is strongly recommended.

NeoBundle 'lambdalisue/vital-ArgumentParser'

Then execute Vitalize as usual like:

:Vitalize --name=your_plugin_name . +ArgumentParser

How to create external vital module

If you want to create some vital modules, you can create it easily. This instruction describes some steps you have to do to create modules.

Create module directory structure

All modules have common directory structure as below:

+- autoload/
|    +- vital/
|         +- __{name}__/
+- doc/

{name} is the same as the argument of :Vitalize --name={name}.

Place module dependant files

You have to place some files. For example, A Foo module has:

+- autoload/
|    +- vital/
|         +- __{name}__/
|              Foo.vim
+- doc/
|    +- vital/
|         +- Foo.txt

These files are:

  • autoload/vital/__{name}__/Foo.vim

    This file has any functions you want to export as you like. All functions must be script local, vital loader will export all alphabetical prefixed functions and won't export all _ prefixed functions.

  • doc/vital/Foo.txt

    This is a normal vim's help file.

Pre-defined functions

There are pre-defined functions for vital loader. These functions tells module's meta data.

  • s:_vital_loaded(V) abort

    This called once when vital is loaded. You can setup some variables for other modules, or any initializations.

    The parameter V is constructed vital loader. You can import other vital modules via this variable.

    The return value will be ignored.

  • s:_vital_depends() abort

    This tells dependencies, will be used when :Vitalize.

    The return value is a dictionary or a list.

  • s:_vital_created(module) abort

    If you create instance-based module, this function is really useful. This is the (fake) constructor for each module instance. This called only once when instance is created.

    When you want to export constant values, you can setup values in this function.

    The parameter module is a new instance.

    The return value will be ignored.

Rules

TBD

Best practice

TBD