Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
add(tsx): it thinks "typescriptreact" is the parser, its actually tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
lmburns committed Sep 2, 2022
1 parent 80d9f7c commit 97f2003
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/syntax-tree-surfer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,16 @@ end --}}}

local function get_nodes_in_array() --{{{
local ts = vim.treesitter
local parser = ts.get_parser(0)
local current_buffer = vim.api.nvim_get_current_buf()

local ok, parser = pcall(ts.get_parser, 0)
if not ok and vim.bo[current_buffer].ft == "typescriptreact" then
parser = ts.get_parser(0, "tsx")
end

local trees = parser:parse()
local root = trees[1]:root()

local current_buffer = vim.api.nvim_get_current_buf()
local nodes = {}

recursive_child_iter(root, nodes)
Expand Down

0 comments on commit 97f2003

Please sign in to comment.