From 166f893b992e721f0adb5d13d6b5ba0842936f13 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 23 Jan 2025 22:09:03 +0100 Subject: [PATCH] fix: nvim 0.10.1 parser pcall() will return two values, the first being a boolean. Check if function exists instead as validation. --- lua/ts-node-action/init.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/ts-node-action/init.lua b/lua/ts-node-action/init.lua index 8804f66..f94d296 100644 --- a/lua/ts-node-action/init.lua +++ b/lua/ts-node-action/init.lua @@ -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