Skip to content

Commit 94f7a29

Browse files
committed
0.9 updates
1 parent f32dff8 commit 94f7a29

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

lua/Comment/jsx.lua

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ local query = [[
2626
[(jsx_fragment) (jsx_element)] @jsx)
2727
]]
2828

29-
local trees = {
30-
typescriptreact = 'tsx',
31-
javascriptreact = 'javascript',
32-
}
33-
3429
---Checks whether parser's language matches the filetype that supports jsx syntax
3530
---@param lang string
3631
---@return boolean
3732
local function is_jsx(lang)
38-
return lang == trees.typescriptreact or lang == trees.javascriptreact
33+
return lang == 'tsx' or lang == 'javascript'
3934
end
4035

4136
-- This function is a workaround for `+` treesitter quantifier
@@ -87,7 +82,7 @@ local function capture(parser, range)
8782
return false
8883
end
8984

90-
local Q = vim.treesitter.query.parse_query(lang, query)
85+
local Q = vim.treesitter.query.parse(lang, query)
9186

9287
local id, lnum, lines = 0, nil, nil
9388

@@ -126,14 +121,7 @@ jsx.commentstring = '{/*%s*/}'
126121
---})
127122
---@usage ]]
128123
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())
137125

138126
if not ok then
139127
return

0 commit comments

Comments
 (0)