diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-08 10:02:44 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-08 10:02:44 +0100 |
| commit | 0508cb652e6ec6c926b8fbaca7c79bdd386252fe (patch) | |
| tree | 2ff308fb639ae03992eaff0fd4b961e4a86526e0 /lua/vis.lua | |
| parent | b33fe9f37d6a9c672650df1c61e897f2582ef563 (diff) | |
| download | vis-0508cb652e6ec6c926b8fbaca7c79bdd386252fe.tar.gz vis-0508cb652e6ec6c926b8fbaca7c79bdd386252fe.tar.xz | |
vis-lua: add optional help parameter to mapping functions
Diffstat (limited to 'lua/vis.lua')
| -rw-r--r-- | lua/vis.lua | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lua/vis.lua b/lua/vis.lua index be46b79..84ebd90 100644 --- a/lua/vis.lua +++ b/lua/vis.lua @@ -22,13 +22,14 @@ end -- return the resulting position. -- @tparam string key the key to associate with the new mption -- @tparam function motion the motion logic implemented as Lua function +-- @tparam[opt] string help the single line help text as displayed in `:help` -- @treturn bool whether the new motion could be installed -- @usage -- vis:motion_new("<C-l>", function(win, pos) -- return pos+1 --- end) +-- end, "Advance to next byte") -- -vis.motion_new = function(vis, key, motion) +vis.motion_new = function(vis, key, motion, help) local id = vis:motion_register(motion) if id < 0 then return false @@ -36,9 +37,9 @@ vis.motion_new = function(vis, key, motion) 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) + vis:map(vis.MODE_NORMAL, key, binding, help) + vis:map(vis.MODE_VISUAL, key, binding, help) + vis:map(vis.MODE_OPERATOR_PENDING, key, binding, help) return true end @@ -50,13 +51,14 @@ end -- expected to return the resulting range or `nil`. -- @tparam string key the key associated with the new text object -- @tparam function textobject the text object logic implemented as Lua function +-- @tparam[opt] string help the single line help text as displayed in `:help` -- @treturn bool whether the new text object could be installed -- @usage -- vis:textobject_new("<C-l>", function(win, pos) -- return pos, pos+1 --- end) +-- end, "Single byte text object") -- -vis.textobject_new = function(vis, key, textobject) +vis.textobject_new = function(vis, key, textobject, help) local id = vis:textobject_register(textobject) if id < 0 then return false @@ -64,8 +66,8 @@ vis.textobject_new = function(vis, key, textobject) local binding = function() vis:textobject(id) end - vis:map(vis.MODE_VISUAL, key, binding) - vis:map(vis.MODE_OPERATOR_PENDING, key, binding) + vis:map(vis.MODE_VISUAL, key, binding, help) + vis:map(vis.MODE_OPERATOR_PENDING, key, binding, help) return true end |
