fix(installer): ignore globally installed parsers

Problem:    `is_installed` is picking up parsers shipped by neovim v0.8
            with unknown version and compatability
Solution:   only consider a parser installed if it's available in the
            parsers_install_dir
This commit is contained in:
kylo252 2022-11-14 10:43:11 +01:00 committed by Christian Clason
parent b79c763c03
commit acb65eedc5
2 changed files with 10 additions and 2 deletions

View file

@ -91,10 +91,18 @@ local function get_installed_revision(lang)
end
end
---Checks if parser is installed with nvim-treesitter
---@param lang string
---@return boolean
local function is_installed(lang)
return #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0
local matched_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) or {}
for _, path in ipairs(matched_parsers) do
local install_dir = configs.get_parser_install_dir()
if vim.startswith(path, install_dir) then
return true
end
end
return false
end
---@param lang string