Skip to content

Commit 55f27e5

Browse files
L3MON4D3github-actions[bot]
authored andcommitted
Format with stylua
1 parent 3a02f54 commit 55f27e5

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

lua/luasnip/extras/lsp.lua

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ local M = {}
1010
---@param offset_encoding string|nil, 'utf-8,16,32' or ni
1111
---@param apply_text_edits_fn function, has to apply regular textEdits, most
1212
--- likely `vim.lsp.util.apply_text_edits` (we expect its' interface).
13-
function M.apply_text_edits(snippet_or_text_edits, bufnr, offset_encoding, apply_text_edits_fn)
13+
function M.apply_text_edits(
14+
snippet_or_text_edits,
15+
bufnr,
16+
offset_encoding,
17+
apply_text_edits_fn
18+
)
1419
-- plain textEdits, applied using via `apply_text_edits_fn`.
1520
local text_edits = {}
1621
-- contains keys
@@ -20,20 +25,37 @@ function M.apply_text_edits(snippet_or_text_edits, bufnr, offset_encoding, apply
2025

2126
for _, v in ipairs(snippet_or_text_edits) do
2227
if v.newText and v.insertTextFormat == 2 then
23-
assert(snippet_params == nil, "Only one snippetTextEdit may be applied at once.")
28+
assert(
29+
snippet_params == nil,
30+
"Only one snippetTextEdit may be applied at once."
31+
)
2432

2533
-- from vim.lsp.apply_text_edits.
2634
local start_row = v.range.start.line
27-
local start_col = vim.lsp.util._get_line_byte_from_position(bufnr, v.range.start, offset_encoding)
28-
local end_row = v.range['end'].line
29-
local end_col = vim.lsp.util._get_line_byte_from_position(bufnr, v.range['end'], offset_encoding)
35+
local start_col = vim.lsp.util._get_line_byte_from_position(
36+
bufnr,
37+
v.range.start,
38+
offset_encoding
39+
)
40+
local end_row = v.range["end"].line
41+
local end_col = vim.lsp.util._get_line_byte_from_position(
42+
bufnr,
43+
v.range["end"],
44+
offset_encoding
45+
)
3046

3147
snippet_params = {
3248
snippet_body = v.newText,
33-
mark = vim.api.nvim_buf_set_extmark(bufnr, luasnip_ns_id, start_row, start_col, {
34-
end_row = end_row,
35-
end_col = end_col
36-
}),
49+
mark = vim.api.nvim_buf_set_extmark(
50+
bufnr,
51+
luasnip_ns_id,
52+
start_row,
53+
start_col,
54+
{
55+
end_row = end_row,
56+
end_col = end_col,
57+
}
58+
),
3759
}
3860
else
3961
table.insert(text_edits, v)
@@ -44,9 +66,14 @@ function M.apply_text_edits(snippet_or_text_edits, bufnr, offset_encoding, apply
4466
apply_text_edits_fn(text_edits, bufnr, offset_encoding)
4567

4668
-- ...then the snippet.
47-
local mark_info = vim.api.nvim_buf_get_extmark_by_id(bufnr, luasnip_ns_id, snippet_params.mark, {details = true})
48-
local mark_begin_pos = {mark_info[1], mark_info[2]}
49-
local mark_end_pos = {mark_info[3].end_row, mark_info[3].end_col}
69+
local mark_info = vim.api.nvim_buf_get_extmark_by_id(
70+
bufnr,
71+
luasnip_ns_id,
72+
snippet_params.mark,
73+
{ details = true }
74+
)
75+
local mark_begin_pos = { mark_info[1], mark_info[2] }
76+
local mark_end_pos = { mark_info[3].end_row, mark_info[3].end_col }
5077

5178
-- luasnip can only expand snippets in the active buffer, so switch (nop if
5279
-- buf already active).

0 commit comments

Comments
 (0)