Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply easy suggestions (part4)
  • Loading branch information
bew committed Nov 10, 2025
commit 85b9618bf87fd3a37019c0567460b801ae8895f2
5 changes: 3 additions & 2 deletions lua/luasnip/extras/fmt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ local rp = require("luasnip.extras").rep
--- counting from the new value (e.g. `{} {3} {}` is `{1} {3} {4}`)
---
---@param fmt string String with placeholders
---@param args {[integer|string]: LuaSnip.Node} Table with list-like and/or map-like keys
---@param args LuaSnip.Node[]|{[string]: LuaSnip.Node} Table with list-like
--- and/or map-like keys
---@param opts? LuaSnip.Opts.Extra.FmtInterpolate
---@return (string|LuaSnip.Node)[] _ A list of strings & elements of `args`
--- inserted into placeholders.
Expand Down Expand Up @@ -175,7 +176,7 @@ end
--- See `interpolate` documentation for details on the format.
---
---@param str string The format string
---@param nodes LuaSnip.Node|LuaSnip.Node[]
---@param nodes LuaSnip.Node|LuaSnip.Node[]|{[string]: LuaSnip.Node}
---@param opts? LuaSnip.Opts.Extra.Fmt
---@return LuaSnip.Node[]
local function format_nodes(str, nodes, opts)
Expand Down
3 changes: 1 addition & 2 deletions lua/luasnip/nodes/functionNode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ function FunctionNode:indent(_) end
function FunctionNode:expand_tabs(_) end

function FunctionNode:make_args_absolute(position_so_far)
self.args_absolute = {}
node_util.make_args_absolute(self.args, position_so_far, self.args_absolute)
self.args_absolute = node_util.make_args_absolute(self.args, position_so_far)
end

function FunctionNode:set_dependents()
Expand Down
3 changes: 2 additions & 1 deletion lua/luasnip/nodes/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ local describe = require("luasnip.util.log").describe
--- snippet node.
---@field indx integer Index of the node in the snippet or snippet node.
---
---(FIXME(@L3MON4D3): Document these)
---@field visible boolean
---@field static_text string[] (FIXME(@bew): What is this for?)
---@field static_text string[]
---@field static_visible boolean
---@field visited boolean
---@field old_text ... (?)
Expand Down
5 changes: 5 additions & 0 deletions lua/luasnip/nodes/snippet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ local function init_snippet_context(context, opts)
util.ternary(context.regTrig ~= nil, "pattern", "plain")
)
engine = trig_engines[engine_name]
if not engine then
error("Unknown trigEngine '".. engine_name.."'")
end
end
---@cast engine -nil (We know it's valid here)

-- make sure to pass through nil-trigEngineOpts, they will be recognized and
-- we will get a default-version of that function instead of generating a
-- curried (?) version of it (which would waste space I think).
Expand Down
14 changes: 8 additions & 6 deletions lua/luasnip/nodes/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,25 @@ end

---@param args LuaSnip.NodeRef[]
---@param parent_insert_position integer[]
---@param target LuaSnip.NormalizedNodeRef[] Target for the normalized node refs
-- FIXME(@bew): Why is the `target` param updated instead of returning a new table?
local function make_args_absolute(args, parent_insert_position, target)
---@return LuaSnip.NormalizedNodeRef[] _ The normalized node refs
local function make_args_absolute(args, parent_insert_position)
---@type LuaSnip.NormalizedNodeRef[]
local normalized_args = {}
for i, arg in ipairs(args) do
if type(arg) == "number" then
-- the arg is a number, should be interpreted relative to direct
-- parent.
local t = vim.deepcopy(parent_insert_position)
table.insert(t, arg)
target[i] = { absolute_insert_position = t }
normalized_args[i] = { absolute_insert_position = t }
else
-- insert node, absolute_indexer, or key itself, node's
-- absolute_insert_position may be nil, check for that during
-- usage.
target[i] = arg
normalized_args[i] = arg
end
end
return normalized_args
end

--- Normarlizes node references
Expand Down Expand Up @@ -866,7 +868,7 @@ local function collect_dependents(node, which, static)
return tbl_util.set_to_list(dependents_set)
end

---@param args string[]?
---@param args (string|LuaSnip.SnippetString)[]?
---@return string[][]?
local function str_args(args)
return args
Expand Down
Loading