Skip to content

Commit

Permalink
fix: nvim 0.10.1 parser
Browse files Browse the repository at this point in the history
pcall() will return two values, the first being a boolean. Check if
function exists instead as validation.
  • Loading branch information
CKolkey committed Jan 23, 2025
1 parent 805dd43 commit 793ed0e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lua/ts-node-action/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ function M.setup(opts)
end

--- @private
--- @return TSNode, string
--- @return nil
--- @return TSNode|nil, string|nil
function M._get_node()
-- stylua: ignore
local parser = (vim.fn.has("nvim-0.12") == 1 and ts.get_parser())
or (vim.fn.has("nvim-0.11") == 1 and ts.get_parser(nil, nil, { error = false }))
or (pcall(ts.get_parser, nil, nil))
or (vim.fn.has("nvim-0.11") == 1 and ts.get_parser(nil, nil, { error = false }))
or (type(ts.get_parser) == "function" and ts.get_parser(nil, nil))

if not parser then
return
Expand Down

0 comments on commit 793ed0e

Please sign in to comment.