From 5bc8c0b1eadea699a0836b6a91549828f58bcf75 Mon Sep 17 00:00:00 2001 From: L3MON4D3 Date: Wed, 20 Sep 2023 14:46:10 +0000 Subject: [PATCH] Format with stylua --- lua/luasnip/extras/_treesitter.lua | 5 ++++- lua/luasnip/extras/treesitter_postfix.lua | 4 ++-- tests/integration/treesitter_postfix_spec.lua | 18 +++++++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lua/luasnip/extras/_treesitter.lua b/lua/luasnip/extras/_treesitter.lua index 0cb8ffd29..e0ac7a3c2 100644 --- a/lua/luasnip/extras/_treesitter.lua +++ b/lua/luasnip/extras/_treesitter.lua @@ -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`. diff --git a/lua/luasnip/extras/treesitter_postfix.lua b/lua/luasnip/extras/treesitter_postfix.lua index a39b75f21..eb41d7738 100644 --- a/lua/luasnip/extras/treesitter_postfix.lua +++ b/lua/luasnip/extras/treesitter_postfix.lua @@ -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 @@ -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 diff --git a/tests/integration/treesitter_postfix_spec.lua b/tests/integration/treesitter_postfix_spec.lua index b68d0995f..dba0a4ffb 100644 --- a/tests/integration/treesitter_postfix_spec.lua +++ b/tests/integration/treesitter_postfix_spec.lua @@ -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. @@ -135,7 +139,8 @@ describe("treesitter-postfix", function() exec("set ft=c") feed("iint main() {\n\tint a = 0;\n\tint b = a;\n}k$i") feed(".mv") - screen:expect{grid=[[ + screen:expect({ + grid = [[ int main() { | int a = 0; | int b = a.mv^; | @@ -143,9 +148,11 @@ describe("treesitter-postfix", function() {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)^; | @@ -153,7 +160,8 @@ describe("treesitter-postfix", function() {0:~ }| {0:~ }| {0:~ }| - {2:-- INSERT --} |]]} + {2:-- INSERT --} |]], + }) end) end end)