@@ -26,16 +26,11 @@ local query = [[
26
26
[(jsx_fragment) (jsx_element)] @jsx)
27
27
]]
28
28
29
- local trees = {
30
- typescriptreact = ' tsx' ,
31
- javascriptreact = ' javascript' ,
32
- }
33
-
34
29
--- Checks whether parser's language matches the filetype that supports jsx syntax
35
30
--- @param lang string
36
31
--- @return boolean
37
32
local function is_jsx (lang )
38
- return lang == trees . typescriptreact or lang == trees . javascriptreact
33
+ return lang == ' tsx ' or lang == ' javascript '
39
34
end
40
35
41
36
-- This function is a workaround for `+` treesitter quantifier
@@ -87,7 +82,7 @@ local function capture(parser, range)
87
82
return false
88
83
end
89
84
90
- local Q = vim .treesitter .query .parse_query (lang , query )
85
+ local Q = vim .treesitter .query .parse (lang , query )
91
86
92
87
local id , lnum , lines = 0 , nil , nil
93
88
@@ -126,14 +121,7 @@ jsx.commentstring = '{/*%s*/}'
126
121
--- })
127
122
--- @usage ]]
128
123
function jsx .calculate (ctx )
129
- local buf = vim .api .nvim_get_current_buf ()
130
- local filetype = vim .api .nvim_buf_get_option (buf , ' filetype' )
131
-
132
- -- NOTE:
133
- -- `get_parser` panics for `{type,java}scriptreact` filetype
134
- -- bcz their parser's name is different from their filetype
135
- -- Maybe report the issue to `nvim-treesitter` or core(?)
136
- local ok , tree = pcall (vim .treesitter .get_parser , buf , trees [filetype ] or filetype )
124
+ local ok , tree = pcall (vim .treesitter .get_parser , vim .api .nvim_get_current_buf ())
137
125
138
126
if not ok then
139
127
return
0 commit comments