diff options
| author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2022-11-14 10:43:11 +0100 |
|---|---|---|
| committer | Christian Clason <christian.clason@uni-due.de> | 2022-11-24 09:25:58 +0100 |
| commit | acb65eedc5d600a96e9b639cd44a7de2c898000d (patch) | |
| tree | 56095ea1df0a786529b8901f68dd3b8ff786879d /lua | |
| parent | fix(fish): update for upstream changes (diff) | |
| download | nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.tar nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.tar.gz nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.tar.bz2 nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.tar.lz nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.tar.xz nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.tar.zst nvim-treesitter-acb65eedc5d600a96e9b639cd44a7de2c898000d.zip | |
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
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 6db2935a0..7cc5c8aa0 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -574,7 +574,7 @@ end ---plugin first, followed by the "site" dir from "runtimepath". "site" dir will ---be created if it doesn't exist. Using only the package dir won't work when ---the plugin is installed with Nix, since the "/nix/store" is read-only. ----@param folder_name string +---@param folder_name string|nil ---@return string|nil, string|nil function M.get_parser_install_dir(folder_name) folder_name = folder_name or "parser" diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 48810b1e2..0f5dccb3a 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -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 |
