vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 132125f6bb35bbef9b2c2826bbf76c64af405f7c
parent 3d3f41b42672d6d0d5ef4130ff688aae7aa937f1
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 17 Feb 2016 23:00:25 +0100

vis-lua: add helper functions to implement motions/text objects in lua

Diffstat:
Mvisrc.lua | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/visrc.lua b/visrc.lua @@ -2,6 +2,33 @@ vis.lexers = require('lexer') vis.events = {} +vis.motion_new = function(vis, key, motion) + local id = vis:motion_register(motion) + if id < 0 then + return false + end + local binding = function() + vis:motion(id) + end + vis:map(vis.MODE_NORMAL, key, binding) + vis:map(vis.MODE_VISUAL, key, binding) + vis:map(vis.MODE_OPERATOR_PENDING, key, binding) + return true +end + +vis.textobject_new = function(vis, key, textobject) + local id = vis:textobject_register(textobject) + if id < 0 then + return false + end + local binding = function() + vis:textobject(id) + end + vis:map(vis.MODE_VISUAL, key, binding) + vis:map(vis.MODE_OPERATOR_PENDING, key, binding) + return true +end + vis.events.win_open = function(win) local files = {