summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorgi Kirilov <>2020-11-22 15:10:50 +0200
committerGeorgi Kirilov <>2023-10-04 18:24:59 +0800
commitd4b729ca15051789cd42473c2aa4b184c4bfabe7 (patch)
treee762dbf0b140870f3eb143a9e8f148c77efb8f11
parentb23c4196a058d4f71d49a95477f937d0d343ebdd (diff)
downloadvis-pairs-d4b729ca15051789cd42473c2aa4b184c4bfabe7.tar.gz
Separate the help text from the delimiters
Fixes adding "universal" brackets in vis-surround.
-rw-r--r--pairs.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/pairs.lua b/pairs.lua
index ed9acd4..307d826 100644
--- a/pairs.lua
+++ b/pairs.lua
@@ -9,13 +9,13 @@ local l = require("lpeg")
local M
local builtin_textobjects = {
- ["["] = { "[" , "]", "[] block" },
- ["{"] = { "{" , "}", "{} block" },
- ["<"] = { "<" , ">", "<> block" },
- ["("] = { "(" , ")", "() block" },
- ['"'] = { '"' , '"', "A quoted string" },
- ["'"] = { "'" , "'", "A single quoted string" },
- ["`"] = { "`" , "`", "A backtick delimited string" },
+ ["["] = { "[" , "]", name = "[] block" },
+ ["{"] = { "{" , "}", name = "{} block" },
+ ["<"] = { "<" , ">", name = "<> block" },
+ ["("] = { "(" , ")", name = "() block" },
+ ['"'] = { '"' , '"', name = "A quoted string" },
+ ["'"] = { "'" , "'", name = "A single quoted string" },
+ ["`"] = { "`" , "`", name = "A backtick delimited string" },
}
local builtin_motions = {
@@ -313,7 +313,7 @@ local function new(execute, register, prefix, handler, help)
table.insert(mappings, win_map(execute == vis.textobject, prefix, binding, help))
local builtin = execute == vis.motion and builtin_motions[prefix] or builtin_textobjects
for key, _ in pairs(builtin) do
- local hlp = (execute == vis.motion and help or "") .. builtin_textobjects[key][3]
+ local hlp = (execute == vis.motion and help or "") .. (builtin_textobjects[key].name or "")
if execute ~= vis.textobject then
vis:map(vis.modes.NORMAL, prefix..key, bind_builtin(key, execute, id), hlp)
end
@@ -366,7 +366,7 @@ vis.events.subscribe(vis.events.INIT, function()
end
end
for key, d in pairs(M.map[1]) do
- builtin_textobjects[key] = {d[1], d[2], d[#d]}
+ builtin_textobjects[key] = {d[1], d[2], name = d[#d]}
builtin_motions[M.prefix.opening][key] = true
builtin_motions[M.prefix.closing][key] = true
end