aboutsummaryrefslogtreecommitdiff
path: root/visrc.lua
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-02-17 23:00:25 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-02-18 16:50:40 +0100
commit0774b6e6933ce3093e2ecda1619c876bc4b85696 (patch)
treee4e5c65fbb57bb7bec894948a17e22f61580bf61 /visrc.lua
parent89486c17e6436fe2cbe10cf4e9f7d385aa35c3fe (diff)
downloadvis-0774b6e6933ce3093e2ecda1619c876bc4b85696.tar.gz
vis-0774b6e6933ce3093e2ecda1619c876bc4b85696.tar.xz
vis-lua: add helper functions to implement motions/text objects in lua
Diffstat (limited to 'visrc.lua')
-rw-r--r--visrc.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/visrc.lua b/visrc.lua
index 469a127..98f4ee9 100644
--- 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 = {