Skip to content

Commit

Permalink
Format with stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
L3MON4D3 committed Sep 21, 2023
1 parent 7865115 commit 5bc8c0b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion lua/luasnip/extras/_treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ function TSParser:get_node_at_pos(pos)
"Invalid position: row and col must be non-negative"
)
local range = { row, col, row, col }
return self.parser:named_node_for_range(range, {ignore_injections = false})
return self.parser:named_node_for_range(
range,
{ ignore_injections = false }
)
end

---Get the root for the smallest tree containing `pos`.
Expand Down
4 changes: 2 additions & 2 deletions lua/luasnip/extras/treesitter_postfix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ local function generate_simple_parent_lookup_function(lookup_fun)
---@param pos { [1]: number, [2]: number }
return function(parser, pos)
-- check node just before the position.
local root = parser:get_node_at_pos({pos[1], pos[2]-1})
local root = parser:get_node_at_pos({ pos[1], pos[2] - 1 })

if root == nil then
return
Expand Down Expand Up @@ -256,7 +256,7 @@ local function find_nth_parent(n)
---@param parser LuaSnip.extra.TSParser
---@param pos { [1]: number, [2]: number }
return function(parser, pos)
local inner_node = parser:get_node_at_pos({pos[1], pos[2]-1})
local inner_node = parser:get_node_at_pos({ pos[1], pos[2] - 1 })

if inner_node == nil then
return
Expand Down
18 changes: 13 additions & 5 deletions tests/integration/treesitter_postfix_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ describe("treesitter-postfix", function()
local err = exec_lua(
[[return {pcall(require, "luasnip.extras.treesitter_postfix")}]]
)[2]
assert(err:match("treesitter_postfix does not support neovim < 0.9"))
assert(
err:match(
"treesitter_postfix does not support neovim < 0.9"
)
)
return
end
-- overrides snippet from previous iteration.
Expand Down Expand Up @@ -135,25 +139,29 @@ describe("treesitter-postfix", function()
exec("set ft=c")
feed("iint main() {\n\tint a = 0;\n\tint b = a;\n}<Esc>k$i")
feed(".mv")
screen:expect{grid=[[
screen:expect({
grid = [[
int main() { |
int a = 0; |
int b = a.mv^; |
} |
{0:~ }|
{0:~ }|
{0:~ }|
{2:-- INSERT --} |]]}
{2:-- INSERT --} |]],
})
exec_lua("ls.expand()")
screen:expect{grid=[[
screen:expect({
grid = [[
int main() { |
int a = 0; |
int b = std::move(a)^; |
} |
{0:~ }|
{0:~ }|
{0:~ }|
{2:-- INSERT --} |]]}
{2:-- INSERT --} |]],
})
end)
end
end)

0 comments on commit 5bc8c0b

Please sign in to comment.