Skip to content

Commit e182352

Browse files
Format with stylua
1 parent 6ced4d3 commit e182352

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

lua/luasnip/extras/expand_conditions.lua

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,42 @@ function M.line_end(line_to_cursor)
1111
end
1212

1313
local memoization_mt = {
14-
__unm = function(o1) return function() return not o1() end end,
15-
__add = function(o1,o2) return function() return o1() or o2() end end,
16-
__mul = function(o1,o2) return function() return o1() and o2() end end,
14+
__unm = function(o1)
15+
return function()
16+
return not o1()
17+
end
18+
end,
19+
__add = function(o1, o2)
20+
return function()
21+
return o1() or o2()
22+
end
23+
end,
24+
__mul = function(o1, o2)
25+
return function()
26+
return o1() and o2()
27+
end
28+
end,
1729
-- TODO more logic operators
1830
__call = function(tab)
1931
if not tab.mem or tab.invalidate(tab) then
2032
tab.mem = tab.func()
2133
end
2234
return tab.mem
23-
end
35+
end,
2436
}
2537
-- low level factory
2638
-- invalidate(table) -> bool: decides if the memoization should be invalidated,
2739
-- can store state in table
2840
-- TODO provide invalidate defaults (buffer, cursor, changes, none)
2941
function M.memoization_factory(func, invalidate)
3042
-- always invalidare by default
31-
invalidate = invalidate or function() return true end
32-
return setmetatable({func=func, invalidate=invalidate}, memoization_mt)
43+
invalidate = invalidate or function()
44+
return true
45+
end
46+
return setmetatable(
47+
{ func = func, invalidate = invalidate },
48+
memoization_mt
49+
)
3350
end
3451

3552
-- F1 = memoization_factory(function() return true end)

0 commit comments

Comments
 (0)