summaryrefslogtreecommitdiffstats
path: root/pairs.lua
diff options
context:
space:
mode:
authorGeorgi Kirilov <>2020-11-22 15:10:49 +0200
committerGeorgi Kirilov <>2023-10-04 18:24:59 +0800
commitddbe96ce0f15bbbf765863d5111c3bb138f62367 (patch)
treeebd86468bdc4a9e89da879682de81fafc8bdcd63 /pairs.lua
parentbd75020fcb95741c2f8fe533d7963d95125580f2 (diff)
downloadvis-pairs-ddbe96ce0f15bbbf765863d5111c3bb138f62367.tar.gz
Insert template for the sexp brackets pairs
Reflects the built-in mapping b - (). Change the table format a bit, to make it easier to specify pairs at once.
Diffstat (limited to 'pairs.lua')
-rw-r--r--pairs.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/pairs.lua b/pairs.lua
index 49af0ee..4230fa3 100644
--- a/pairs.lua
+++ b/pairs.lua
@@ -106,9 +106,9 @@ local function get_delimiters(key, pos)
if not d or type(d[1]) == "string" and type(d[2]) == "string" then return d end
local start, finish = get_range(key, vis.win.file, pos)
if start and finish then
- return {vis.win.file:content(start[1], start[2] - start[1]), vis.win.file:content(finish[1], finish[2] - finish[1]), {d[3], d[4]}, d[5]}
+ return {vis.win.file:content(start[1], start[2] - start[1]), vis.win.file:content(finish[1], finish[2] - finish[1]), d[3], d[4]}
elseif #d > 2 then
- return {nil, nil, {d[3], d[4]}, d[5]}
+ return {nil, nil, d[3], d[4]}
end
end
@@ -191,11 +191,11 @@ vis.events.subscribe(vis.events.INIT, function()
outer = new(vis.textobject, vis.textobject_register, M.prefix.outer, outer, "Delimited block (outer variant)"),
}
- local tex_environment = {"\\begin{" * l.Cg(l.C(l.R("az", "AZ")^1), "t") * "}", l.Cmt("\\end{" * l.Cb("t") * l.C((1 - l.P"}")^1) * "}", function(_, _, c1, c2) return c1 == c2 end), "\\begin{\255\253}", "\\end{\255\253}", "environment name"}
- local tag = {"<" * l.Cg(l.C((l.S"_:" + l.R("az", "AZ")) * (l.R("az", "AZ", "09") + l.S"_:.-")^0), "t") * (1 - l.S"><")^0 * (">" - l.B"/"), l.Cmt("</" * l.Cb("t") * l.C((1 - l.P">")^1) * ">", function(_, _, c1, c2) return c1 == c2 end), "<\255\253>", "</\255\253>", "tag name"}
- local function any_pair(set) return {l.Cg(l.C(l.S(set)), "s"), l.Cmt(l.Cb("s") * l.C(1), function(_, _, c1, c2) return builtin_textobjects[c1][2] == c2 end)} end
+ local tex_environment = {"\\begin{" * l.Cg(l.C(l.R("az", "AZ")^1), "t") * "}", l.Cmt("\\end{" * l.Cb("t") * l.C((1 - l.P"}")^1) * "}", function(_, _, c1, c2) return c1 == c2 end), {"\\begin{\255\253}", "\\end{\255\253}"}, "environment name"}
+ local tag = {"<" * l.Cg(l.C((l.S"_:" + l.R("az", "AZ")) * (l.R("az", "AZ", "09") + l.S"_:.-")^0), "t") * (1 - l.S"><")^0 * (">" - l.B"/"), l.Cmt("</" * l.Cb("t") * l.C((1 - l.P">")^1) * ">", function(_, _, c1, c2) return c1 == c2 end), {"<\255\253>", "</\255\253>"}, "tag name"}
+ local function any_pair(set, default) return {l.Cg(l.C(l.S(set)), "s"), l.Cmt(l.Cb("s") * l.C(1), function(_, _, c1, c2) return builtin_textobjects[c1][2] == c2 end), builtin_textobjects[default]} end
local any_quote = any_pair("'`\"")
- local any_bracket = any_pair("({[")
+ local any_bracket = any_pair("({[", "(")
local presets = {
{q = any_quote},
html = {t = tag},