aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-06-12 15:58:43 +0100
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit041f117fb182acb56831a204c286622fb43574c1 (patch)
treea3c16e9d3fc32f0527d04745bde6ad0bfd3121c9
parentfeat: add parser tiers (diff)
downloadnvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.tar
nvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.tar.gz
nvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.tar.bz2
nvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.tar.lz
nvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.tar.xz
nvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.tar.zst
nvim-treesitter-041f117fb182acb56831a204c286622fb43574c1.zip
fix: filter languages through parser.configs
-rw-r--r--lua/nvim-treesitter/config.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/lua/nvim-treesitter/config.lua b/lua/nvim-treesitter/config.lua
index 7ffb23a46..c216a0b15 100644
--- a/lua/nvim-treesitter/config.lua
+++ b/lua/nvim-treesitter/config.lua
@@ -86,7 +86,7 @@ end
---Normalize languages
---@param languages? string[]|string
----@param skip? table
+---@param skip? { ignored: boolean, missing: boolean, installed: boolean, dependencies: boolean }
---@return string[]
function M.norm_languages(languages, skip)
if not languages then
@@ -103,7 +103,6 @@ function M.norm_languages(languages, skip)
end
languages = parsers.get_available()
end
- --TODO(clason): skip and warn on unavailable parser
-- keep local to avoid leaking parsers module
local function expand_tiers(list)
@@ -142,6 +141,11 @@ function M.norm_languages(languages, skip)
end, languages) --[[@as string[] ]]
end
+ languages = vim.iter.filter(function(v)
+ -- TODO(lewis6991): warn of any unknown parsers?
+ return parsers.configs[v] ~= nil
+ end, languages) --[[@as string[] ]]
+
if not (skip and skip.dependencies) then
for _, lang in pairs(languages) do
if parsers.configs[lang].requires then