fix(install): skip tier 4 parsers when installing and updating

This commit is contained in:
Christian Clason 2025-03-26 13:08:49 +01:00
parent 9365cf8a97
commit 328ee3db54
6 changed files with 51 additions and 40 deletions

View file

@ -27,8 +27,10 @@ function M.setup(user_data)
end
if #config.ensure_install > 0 then
local to_install = M.norm_languages(config.ensure_install, { ignored = true, installed = true })
local to_install = M.norm_languages(
config.ensure_install,
{ ignored = true, installed = true, unsupported = true }
)
if #to_install > 0 then
require('nvim-treesitter.install').install(to_install, { force = true })
end
@ -103,7 +105,7 @@ end
---Normalize languages
---@param languages? string[]|string
---@param skip? { ignored: boolean, missing: boolean, installed: boolean, dependencies: boolean }
---@param skip? { ignored: boolean, missing: boolean, unsupported: boolean, installed: boolean, dependencies: boolean }
---@return string[]
function M.norm_languages(languages, skip)
if not languages then
@ -164,6 +166,16 @@ function M.norm_languages(languages, skip)
languages
)
if skip and skip.unsupported then
languages = vim.tbl_filter(
--- @param v string
function(v)
return parsers[v].tier < 4
end,
languages
)
end
if not (skip and skip.dependencies) then
for _, lang in pairs(languages) do
if parsers[lang].requires then