Module vpe.core

Enhanced module for using Python3 in Vim.

This provides the Vim class, which is a wrapper around Vim’s built-in vim module. It is intended that a Vim instance can be uses as a replacement for the vim module. For example:

from vpe import vim
# Now use 'vim' as an extended version of the *vim* module.
# ...

This was developed for Vim version 8.1. It will probably work for Vim 8.0, but is very unlikely to be compatible with earlier versions. I plan that future versions of vpe will be backwardly compatible with version 8.1.

Callback

class core.Callback(...)
Callback(
    func,
    *,
    py_args=(),
    py_kwargs={},
    vim_args=(),
    pass_bytes=False,
    info=())

Wrapper for a function to be called from Vim.

Parameters

func

The function to be invoked.

py_args

Positional arguments for the function.

py_kwargs

Keyword arguments for the function.

vim_args

Positional arguments for helper Vim function.

pass_bytes

If true then vim byte-strings will not be decoded to Python strings.

info

Additional info to store with the callback. TODO: Only really for MapCallback!

Methods

as_call()

Format a command of the form ‘call VPE_xxx(…)’

The result can be used as a colon prompt command.

as_invocation()

Format a command of the form ‘VPE_xxx(…)’

The result is a valid Vim script expression.

as_vim_function()

Create a vim.Function that will route to this callback.

Class methods

classmethod invoke()

Invoke this callback function.

classmethod on_del(_, uid)

“Handle deletion of weak reference to method’s instance.

expr_arg

class core.expr_arg(arg: str)

Wrapper for a Vim argument that is an expression.

This is used to wrap a string that represents an expression that should be passed to a Vim function, without being quoted.

Parameters

arg

The argument as a string representing the Vim expression.