Skip to content

Commit 326779d

Browse files
L3MON4D3github-actions[bot]
authored andcommitted
Format with stylua
1 parent c7ca34f commit 326779d

File tree

9 files changed

+45
-27
lines changed

9 files changed

+45
-27
lines changed

lua/luasnip/init.lua

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ local function store_cursor_node_relative(node)
155155

156156
store_id = store_id + 1
157157

158-
snip_data.cursor_end_relative = util.pos_sub(util.get_cursor_0ind(), node.mark:get_endpoint(1))
158+
snip_data.cursor_end_relative =
159+
util.pos_sub(util.get_cursor_0ind(), node.mark:get_endpoint(1))
159160

160161
data[snip] = snip_data
161162

@@ -167,24 +168,23 @@ end
167168

168169
local function get_corresponding_node(parent, data)
169170
return parent:find_node(function(test_node)
170-
return (test_node.store_id == data.store_id) or (data.key ~= nil and test_node.key == data.key)
171+
return (test_node.store_id == data.store_id)
172+
or (data.key ~= nil and test_node.key == data.key)
171173
end)
172174
end
173175

174176
local function restore_cursor_pos_relative(node, data)
175177
util.set_cursor_0ind(
176-
util.pos_add(
177-
node.mark:get_endpoint(1),
178-
data.cursor_end_relative
179-
)
178+
util.pos_add(node.mark:get_endpoint(1), data.cursor_end_relative)
180179
)
181180
end
182181

183182
local function node_update_dependents_preserve_position(node, opts)
184183
local restore_data = store_cursor_node_relative(node)
185184

186185
-- update all nodes that depend on this one.
187-
local ok, res = pcall(node.update_dependents, node, {own=true, parents=true})
186+
local ok, res =
187+
pcall(node.update_dependents, node, { own = true, parents = true })
188188
if not ok then
189189
local snip = node:get_snippet()
190190

@@ -194,7 +194,10 @@ local function node_update_dependents_preserve_position(node, opts)
194194
snip.trigger,
195195
res
196196
)
197-
return { jump_done = false, new_node = session.current_nodes[vim.api.nvim_get_current_buf()] }
197+
return {
198+
jump_done = false,
199+
new_node = session.current_nodes[vim.api.nvim_get_current_buf()],
200+
}
198201
end
199202

200203
-- update successful => check if the current node is still visible.
@@ -228,11 +231,17 @@ local function node_update_dependents_preserve_position(node, opts)
228231
-- since the node was no longer visible after an update, it must have
229232
-- been contained in a dynamicNode, and we don't have to handle the
230233
-- case that we can't find it.
231-
while node_parent.dynamicNode == nil or node_parent.dynamicNode.visible == false do
234+
while
235+
node_parent.dynamicNode == nil
236+
or node_parent.dynamicNode.visible == false
237+
do
232238
node_parent = node_parent.parent
233239
end
234240
local d = node_parent.dynamicNode
235-
assert(d.active, "Visible dynamicNode that was a parent of the current node is not active after the update!! If you get this message, please open an issue with LuaSnip!")
241+
assert(
242+
d.active,
243+
"Visible dynamicNode that was a parent of the current node is not active after the update!! If you get this message, please open an issue with LuaSnip!"
244+
)
236245

237246
local new_node = get_corresponding_node(d, snip_restore_data)
238247

@@ -248,7 +257,10 @@ local function node_update_dependents_preserve_position(node, opts)
248257
else
249258
-- could not find corresponding node -> just jump into the
250259
-- dynamicNode that should have generated it.
251-
return { jump_done = true, new_node = d:jump_into_snippet(opts.no_move) }
260+
return {
261+
jump_done = true,
262+
new_node = d:jump_into_snippet(opts.no_move),
263+
}
252264
end
253265
end
254266
end
@@ -262,7 +274,10 @@ local function safe_jump_current(dir, no_move, dry_run)
262274

263275
-- don't update for -1-node.
264276
if not dry_run and node.pos >= 0 then
265-
local upd_res = node_update_dependents_preserve_position(node, { no_move = no_move, restore_position = false })
277+
local upd_res = node_update_dependents_preserve_position(
278+
node,
279+
{ no_move = no_move, restore_position = false }
280+
)
266281
if upd_res.jump_done then
267282
return upd_res.new_node
268283
else
@@ -599,7 +614,10 @@ local function active_update_dependents()
599614
-- don't update if a jump/change_choice is in progress, or if we don't have
600615
-- an active node.
601616
if not session.jump_active and active ~= nil then
602-
local upd_res = node_update_dependents_preserve_position(active, { no_move = false, restore_position = true })
617+
local upd_res = node_update_dependents_preserve_position(
618+
active,
619+
{ no_move = false, restore_position = true }
620+
)
603621
session.current_nodes[vim.api.nvim_get_current_buf()] = upd_res.new_node
604622
end
605623
end

lua/luasnip/nodes/choiceNode.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function ChoiceNode:set_choice(choice, current_node)
270270
self.active_choice:subtree_set_pos_rgrav(to, -1, true)
271271

272272
self.active_choice:update_restore()
273-
self:update_dependents({own=true, parents=true, children=true})
273+
self:update_dependents({ own = true, parents = true, children = true })
274274

275275
-- Another node may have been entered in update_dependents.
276276
self:focus()

lua/luasnip/nodes/dynamicNode.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function DynamicNode:update()
209209
-- (and thus have changed text after this update), and all of the
210210
-- children's depedents (since they may have dependents outside this
211211
-- dynamicNode, who have not yet been updated)
212-
self:update_dependents({own=true, children=true, parents=true})
212+
self:update_dependents({ own = true, children = true, parents = true })
213213
end
214214

215215
local update_errorstring = [[
@@ -298,7 +298,7 @@ function DynamicNode:update_static()
298298

299299
tmp:update_static()
300300
-- updates own dependents.
301-
self:update_dependents_static({own=true, parents=true, children=true})
301+
self:update_dependents_static({ own = true, parents = true, children = true })
302302
end
303303

304304
function DynamicNode:exit()

lua/luasnip/nodes/functionNode.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function FunctionNode:update()
6060

6161
-- assume that functionNode can't have a parent as its dependent, there is
6262
-- no use for that I think.
63-
self:update_dependents({own=true, parents=true})
63+
self:update_dependents({ own = true, parents = true })
6464
end
6565

6666
local update_errorstring = [[

lua/luasnip/nodes/insertNode.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ local function I(pos, static_text, opts)
2020
-- will only be needed for 0-node, -1-node isn't set with this.
2121
ext_gravities_active = { false, false },
2222
inner_active = false,
23-
input_active = false
23+
input_active = false,
2424
}, opts)
2525
else
2626
return InsertNode:new({
@@ -30,7 +30,7 @@ local function I(pos, static_text, opts)
3030
dependents = {},
3131
type = types.insertNode,
3232
inner_active = false,
33-
input_active = false
33+
input_active = false,
3434
}, opts)
3535
end
3636
end

lua/luasnip/nodes/node.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,11 @@ function Node:set_text(text)
533533

534534
if self:get_snippet().___static_expanded then
535535
self.static_text = text_indented
536-
self:update_dependents_static({own=true, parents=true})
536+
self:update_dependents_static({ own = true, parents = true })
537537
else
538538
if self.visible then
539539
self:set_text_raw(text_indented)
540-
self:update_dependents({own=true, parents=true})
540+
self:update_dependents({ own = true, parents = true })
541541
end
542542
end
543543
end

lua/luasnip/nodes/snippet.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,6 @@ function Snippet:trigger_expand(current_node, pos_id, env, indent_nodes)
638638
-- enter current node, it will contain the new snippet.
639639
current_node:input_enter_children()
640640
end
641-
642641
else
643642
-- if no parent_node, completely leave.
644643
node_util.refocus(current_node, nil)
@@ -753,7 +752,7 @@ function Snippet:trigger_expand(current_node, pos_id, env, indent_nodes)
753752
self.mark = mark(old_pos, pos, mark_opts)
754753

755754
self:update()
756-
self:update_dependents({children=true})
755+
self:update_dependents({ children = true })
757756

758757
-- Marks should stay at the beginning of the snippet, only the first mark is needed.
759758
start_node.mark = self.nodes[1].mark

lua/luasnip/nodes/util.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,6 @@ local function node_subtree_do(node, opts)
812812
node:subtree_do(opts)
813813
end
814814

815-
816815
local function collect_dependents(node, which, static)
817816
local dependents_set = {}
818817

@@ -846,7 +845,7 @@ local function collect_dependents(node, which, static)
846845
dependents_set[dep] = true
847846
end
848847
end,
849-
static = static
848+
static = static,
850849
})
851850
end
852851

@@ -877,5 +876,5 @@ return {
877876
nodelist_adjust_rgravs = nodelist_adjust_rgravs,
878877
find_node_dependents = find_node_dependents,
879878
collect_dependents = collect_dependents,
880-
node_subtree_do = node_subtree_do
879+
node_subtree_do = node_subtree_do,
881880
}

tests/integration/session_spec.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,9 @@ describe("session", function()
20302030
-- issue with it.
20312031
-- => when the dynamicNode is left during `refocus`, the deletion
20322032
-- will be detected, and snippet removed from the jumplist.
2033-
exec_lua([[vim.api.nvim_buf_del_extmark(0, ls.session.ns_id, ls.session.current_nodes[1].mark.id)]])
2033+
exec_lua(
2034+
[[vim.api.nvim_buf_del_extmark(0, ls.session.ns_id, ls.session.current_nodes[1].mark.id)]]
2035+
)
20342036

20352037
feed("Gofn")
20362038
expand()

0 commit comments

Comments
 (0)