Skip to content

Commit 63925f0

Browse files
add xnor operator
1 parent d4f8be1 commit 63925f0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/luasnip/extras/expand_conditions.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ function M.line_end(line_to_cursor)
1111
end
1212

1313
local memoization_mt = {
14+
-- logic operators
15+
-- not
1416
__unm = function(o1) return function(...) return not o1(...) end end,
17+
-- or
1518
__add = function(o1,o2) return function(...) return o1(...) or o2(...) end end,
19+
-- and
1620
__mul = function(o1,o2) return function(...) return o1(...) and o2(...) end end,
17-
-- TODO more logic operators
21+
-- xnor
22+
__eq = function(o1,o2) return function(...) return o1(...) == o2(...) end end,
23+
-- use table like a function by overloading __call
1824
__call = function(tab, line_to_cursor, matched_trigger, captures)
1925
if not tab.mem or tab.invalidate(tab, line_to_cursor, matched_trigger, captures) then
2026
tab.mem = tab.func(line_to_cursor, matched_trigger, captures)

0 commit comments

Comments
 (0)