fix(treesitter): adapt to upstream change (#3308)

In Nvim 0.11, `vim.treesitter.language.add()` returns `true` on success
or `nil,errmsg` on failure instead of throwing an error.
This commit is contained in:
Christian Clason
2024-09-30 08:56:14 +02:00
committed by GitHub
parent cb3f98d935
commit eae0d8fbde

View File

@@ -662,8 +662,12 @@ end)
--- Checks if treesitter parser for language is installed --- Checks if treesitter parser for language is installed
---@param lang string ---@param lang string
utils.has_ts_parser = function(lang) utils.has_ts_parser = function(lang)
if vim.fn.has "nvim-0.11" == 1 then
return vim.treesitter.language.add(lang)
else
return pcall(vim.treesitter.language.add, lang) return pcall(vim.treesitter.language.add, lang)
end end
end
--- Telescope Wrapper around vim.notify --- Telescope Wrapper around vim.notify
---@param funname string: name of the function that will be ---@param funname string: name of the function that will be