Skip to content
Iury O. G. Figueiredo edited this page Dec 30, 2019 · 4 revisions

Command plugins don't define a install function the plugin file. They implement functions to be executed at runtime, these functtions can perform any kind of tasks that varies from changing AreaVi instances mode to connecting to IRC Networks.

A simple example

Consider the situation that you wanted to implement a plugin that exposed a function to be executed from vy and it outputed on a given AreaVi instance the actual date.

Create a file named:

~/.vy/insert_date.py 

Place the following code in it:

from vyapp.plugins import Command
import time

@Command()
def date(area):
    area.insert('insert', time.strftime("%d/%m/%Y"))

Import the plugin from your ~/.vy/vyrc file with:

import insert_date

Run vy then press the keycommand below in GLOBAL mode to drop python code:

<Alt-semicolon>

Move the vy cursor to a position where you would like to insert current date then drop the following statement:

date()

Now, you have created your first vy command plugin !

The vyrc file is executed using vyapp.plugins.ENV as environment, it means that whatever it is defined inside ~/.vy/vyrc it will be defined in vyapp.plugins.ENV. It means the vy command created by the plugin above could be defined inside the ~/.vy/vyrc file by defining the date function inside the ~/vy/.vyrc file although it doesn't sound good.

Clone this wiki locally