Skip to content

Commit

Permalink
BREAKING CHANGE: Move pseudo-nodes from ls.util.functions to ls.extras.
Browse files Browse the repository at this point in the history
Pseudo-nodes were previously separated based on whether they rely on
lambdas, which doesn't make much sense. Now all Pseudo-nodes will be in
luasnip.extras.
  • Loading branch information
L3MON4D3 committed Jul 24, 2021
1 parent 02f7c2b commit e9f4d03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Examples/snippets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local l = require("luasnip.extras").lambda
local r = require("luasnip.util.functions").rep
local p = require("luasnip.util.functions").partial
local r = require("luasnip.extras").rep
local p = require("luasnip.extras").partial

-- Every unspecified option will be set to the default.
ls.config.set_config({
Expand Down
13 changes: 13 additions & 0 deletions lua/luasnip/extras/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ end
return {
lambda = lambda,
match = match,
-- repeat a node.
rep = function(node_indx)
return F(function(args)
return args[1]
end, node_indx)
end,
-- Insert the output of a function.
partial = function(func, ...)
return F(function(_, fn, ...)
return fn(...)
end, {}, func, ...)
end,

--alias
l = lambda,
m = match,
Expand Down
14 changes: 0 additions & 14 deletions lua/luasnip/util/functions.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local f = require("luasnip.nodes.functionNode").F

return {
-- supported lsp-vars.
lsp = {
Expand All @@ -18,16 +16,4 @@ return {
copy = function(args)
return args[1]
end,
-- repeat a node.
rep = function(node_indx)
return f(function(args)
return args[1]
end, node_indx)
end,
-- Insert the output of a function.
partial = function(func, ...)
return f(function(_, fn, ...)
return fn(...)
end, {}, func, ...)
end,
}

0 comments on commit e9f4d03

Please sign in to comment.