diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2025-03-26 13:08:49 +0100 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 328ee3db548db585208ae2ff0bf4fd06231581aa (patch) | |
| tree | acbcebfa02d3254b011ee8e40738bdd7ebc05429 /lua | |
| parent | fix(install): don't prompt on installed parsers (skip) (diff) | |
| download | nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.tar nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.tar.gz nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.tar.bz2 nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.tar.lz nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.tar.xz nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.tar.zst nvim-treesitter-328ee3db548db585208ae2ff0bf4fd06231581aa.zip | |
fix(install): skip tier 4 parsers when installing and updating
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/config.lua | 18 | ||||
| -rw-r--r-- | lua/nvim-treesitter/health.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/indent.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 19 | ||||
| -rw-r--r-- | lua/nvim-treesitter/locals.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 48 |
6 files changed, 51 insertions, 40 deletions
diff --git a/lua/nvim-treesitter/config.lua b/lua/nvim-treesitter/config.lua index 473a97ee9..7ef5aeddf 100644 --- a/lua/nvim-treesitter/config.lua +++ b/lua/nvim-treesitter/config.lua @@ -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 diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index 1776cffe7..68b01bb35 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -25,7 +25,7 @@ local function install_health() do -- nvim check if vim.fn.has('nvim-0.11') ~= 1 then - health.error('Nvim-treesitter requires the latest Neovim nightly') + health.error('Nvim-treesitter requires Neovim 0.11.0 or later.') end if vim.treesitter.language_version then diff --git a/lua/nvim-treesitter/indent.lua b/lua/nvim-treesitter/indent.lua index 6b674dc63..03489f22e 100644 --- a/lua/nvim-treesitter/indent.lua +++ b/lua/nvim-treesitter/indent.lua @@ -134,7 +134,7 @@ function M.get_indent(lnum) end -- Get language tree with smallest range around node that's not a comment parser - local root, lang_tree ---@type TSNode, LanguageTree + local root, lang_tree ---@type TSNode, vim.treesitter.LanguageTree parser:for_each_tree(function(tstree, tree) if not tstree or M.comment_parsers[tree:lang()] then return diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index d49a7cbc9..c208a2709 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -148,7 +148,7 @@ local function do_generate(logger, repo, compile_location) 'generate', '--abi', tostring(vim.treesitter.language_version), - repo.generate_from_json and 'src/grammar.json', + repo.generate_from_json and 'src/grammar.json' or nil, }, { cwd = compile_location }) if r.code > 0 then return logger:error('Error during "tree-sitter generate": %s', r.stderr) @@ -432,14 +432,12 @@ local function install(languages, options, callback) end end +---@param languages string[] +---@param options? InstallOptions +---@param callback? fun(boolean) M.install = a.sync(function(languages, options, callback) reload_parsers() - if not languages or #languages == 0 then - languages = 'all' - end - - languages = config.norm_languages(languages, options and options.skip) - + languages = config.norm_languages(languages, { ignored = true, unsupported = true }) install(languages, options, callback) end, 3) @@ -447,13 +445,14 @@ end, 3) ---@param languages? string[]|string ---@param _options? UpdateOptions ----@param callback function +---@param callback? function M.update = a.sync(function(languages, _options, callback) reload_parsers() if not languages or #languages == 0 then languages = 'all' end - languages = config.norm_languages(languages, { ignored = true, missing = true }) + languages = + config.norm_languages(languages, { ignored = true, missing = true, unsupported = true }) languages = vim.tbl_filter(needs_update, languages) ---@type string[] if #languages > 0 then @@ -501,7 +500,7 @@ end ---@param languages string[]|string ---@param _options? UpdateOptions ----@param _callback fun() +---@param _callback? fun() M.uninstall = a.sync(function(languages, _options, _callback) languages = config.norm_languages(languages or 'all', { missing = true, dependencies = true }) diff --git a/lua/nvim-treesitter/locals.lua b/lua/nvim-treesitter/locals.lua index c8ebe0b0d..63b3d458c 100644 --- a/lua/nvim-treesitter/locals.lua +++ b/lua/nvim-treesitter/locals.lua @@ -159,7 +159,7 @@ local function get_root(bufnr) end ---@param bufnr integer: the buffer ----@return Query|nil query: `locals` query +---@return vim.treesitter.Query|nil query: `locals` query ---@return TSNode|nil root: root node of the bufferocal function get_query(bufnr) local function get_query(bufnr) local root = get_root(bufnr) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 32ef7cdee..263985ecf 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -19,7 +19,7 @@ return { angular = { install_info = { generate_from_json = true, - revision = 'be53f2597dded40c90b5f53ed9f4521422f6b6b3', + revision = '843525141575e397541e119698f0532755e959f6', url = 'https://github.com/dlvandenberg/tree-sitter-angular', }, maintainers = { '@dlvandenberg' }, @@ -447,7 +447,7 @@ return { }, editorconfig = { install_info = { - revision = '02f562e71dc28d573187809eecdffaee7c82321c', + revision = '3f2b371537355f6e53cc3af37f79ba450efb5132', url = 'https://github.com/ValdezFOmar/tree-sitter-editorconfig', }, maintainers = { '@ValdezFOmar' }, @@ -510,7 +510,7 @@ return { }, enforce = { install_info = { - revision = '8201c3c354c34b96d5a531c8e63d262209ee06cb', + revision = 'aedd0bbab9dcc9caec9cc4e32bd303e86509522b', url = 'https://github.com/simonvic/tree-sitter-enforce', }, maintainers = { '@simonvic' }, @@ -518,7 +518,7 @@ return { }, erlang = { install_info = { - revision = '364e323b32d098ad0e7b29e7adb4005c2bb5cf34', + revision = '416ca60d7d2a824c0d346163541153e230710780', url = 'https://github.com/WhatsApp/tree-sitter-erlang', }, maintainers = { '@filmor' }, @@ -591,7 +591,7 @@ return { }, fortran = { install_info = { - revision = '64e11001d7ef3e8ac18e55a3a2d811fe36430923', + revision = 'd738334e4a21866a1ab81fb3f27f9b0b2ad2e515', url = 'https://github.com/stadelmanma/tree-sitter-fortran', }, maintainers = { '@amaanq' }, @@ -726,7 +726,7 @@ return { glimmer_javascript = { install_info = { generate_from_json = true, - revision = 'babba3fc0c822a633261ce9e96a4d7986050eb0c', + revision = '5cc865a2a0a77cbfaf5062c8fcf2a9919bd54f87', url = 'https://github.com/NullVoxPopuli/tree-sitter-glimmer-javascript', }, maintainers = { '@NullVoxPopuli' }, @@ -736,7 +736,7 @@ return { glimmer_typescript = { install_info = { generate_from_json = true, - revision = '48c60295f1ee34ea4ed6e5177102be6d24bfc9d0', + revision = '12d98944c1d5077b957cbdb90d663a7c4d50118c', url = 'https://github.com/NullVoxPopuli/tree-sitter-glimmer-typescript', }, maintainers = { '@NullVoxPopuli' }, @@ -900,7 +900,7 @@ return { }, hcl = { install_info = { - revision = '9e3ec9848f28d26845ba300fd73c740459b83e9b', + revision = 'de10d494dbd6b71cdf07a678fecbf404dbfe4398', url = 'https://github.com/tree-sitter-grammars/tree-sitter-hcl', }, maintainers = { '@MichaHoffmann' }, @@ -992,7 +992,7 @@ return { }, http = { install_info = { - revision = '77ecf6385f1b5d422e0bbd12204374d287d61ad2', + revision = 'db8b4398de90b6d0b6c780aba96aaa2cd8e9202c', url = 'https://github.com/rest-nvim/tree-sitter-http', }, maintainers = { '@amaanq', '@NTBBloodbath' }, @@ -1082,7 +1082,7 @@ return { }, javadoc = { install_info = { - revision = 'db9589e9c61cff7d7fcc207744c711b10b60a7a3', + revision = '330cc9cb4f33545f7bfce6c3b6aa77fe6db1b537', url = 'https://github.com/rmuir/tree-sitter-javadoc', }, maintainers = { '@rmuir' }, @@ -1223,7 +1223,7 @@ return { }, koto = { install_info = { - revision = '673511402dfef07b25cfa43991693b8442695fc7', + revision = '46770abba021e2ddd2c51d9fa3087fd1ab6b2aea', url = 'https://github.com/koto-lang/tree-sitter-koto', }, maintainers = { '@irh' }, @@ -1399,7 +1399,7 @@ return { }, meson = { install_info = { - revision = '9c74e8e8917b83d90e38ac040949079437ec0043', + revision = 'a56af662e8540412fed5e40cc20435b2b9a20502', url = 'https://github.com/tree-sitter-grammars/tree-sitter-meson', }, maintainers = { '@Decodetalkers' }, @@ -1489,7 +1489,7 @@ return { }, nu = { install_info = { - revision = 'c10340b5bb3789f69182acf8f34c3d4fc24d2fe1', + revision = 'd5c71a10b4d1b02e38967b05f8de70e847448dd1', url = 'https://github.com/nushell/tree-sitter-nu', }, maintainers = { '@abhisheksingh0x558' }, @@ -1577,7 +1577,7 @@ return { install_info = { branch = 'release', generate_from_json = true, - revision = 'bb53f204aa3e7507960014642965c9f9a9e84b1d', + revision = 'ecd90bd8b381bcc7219fed4fe351903630e761c6', url = 'https://github.com/tree-sitter-perl/tree-sitter-perl', }, maintainers = { '@RabbiVeesh', '@LeoNerd' }, @@ -1586,7 +1586,7 @@ return { php = { install_info = { location = 'php', - revision = 'f7cf7348737d8cff1b13407a0bfedce02ee7b046', + revision = '576a56fa7f8b68c91524cdd211eb2ffc43e7bb11', url = 'https://github.com/tree-sitter/tree-sitter-php', }, maintainers = { '@tk-shirasaka', '@calebdw' }, @@ -1597,7 +1597,7 @@ return { php_only = { install_info = { location = 'php_only', - revision = 'f7cf7348737d8cff1b13407a0bfedce02ee7b046', + revision = '576a56fa7f8b68c91524cdd211eb2ffc43e7bb11', url = 'https://github.com/tree-sitter/tree-sitter-php', }, maintainers = { '@tk-shirasaka', '@calebdw' }, @@ -1803,7 +1803,7 @@ return { qmljs = { install_info = { generate_from_json = true, - revision = '8fef30e231d74b65c713bcbac21956156d8963da', + revision = '0889da4632bba3ec6f39ef4102625654890c15c1', url = 'https://github.com/yuja/tree-sitter-qmljs', }, maintainers = { '@Decodetalkers' }, @@ -1990,7 +1990,7 @@ return { }, scala = { install_info = { - revision = '42a1542248ff611ba2091fe76c6dbf42551ebef8', + revision = 'c1189954df854977c3a52003ca8a247c5f4729ba', url = 'https://github.com/tree-sitter/tree-sitter-scala', }, maintainers = { '@stevanmilic' }, @@ -2188,7 +2188,7 @@ return { superhtml = { install_info = { location = 'tree-sitter-superhtml', - revision = 'fc7c594f52528e4a4a08671137850143d55a5bf2', + revision = '16887e9fa3122c36a3d4942470e33c1c282fe859', url = 'https://github.com/kristoff-it/superhtml', }, maintainers = { '@rockorager' }, @@ -2263,7 +2263,7 @@ return { }, tact = { install_info = { - revision = 'a19be2d4c1956e12facfc717e28f13a6ad0860e0', + revision = '47af20264abbd24ea282ded0f8ee9cad3cf3bf2f', url = 'https://github.com/tact-lang/tree-sitter-tact', }, maintainers = { '@novusnota' }, @@ -2271,7 +2271,7 @@ return { }, tcl = { install_info = { - revision = '98015ebe182d94e5a4439e32ffd91beaac32fcb9', + revision = 'f15e711167661d1ba541d4f62b9dbfc4ce61ec56', url = 'https://github.com/tree-sitter-grammars/tree-sitter-tcl', }, maintainers = { '@lewis6991' }, @@ -2297,7 +2297,7 @@ return { }, tera = { install_info = { - revision = '482b475b32e6bae67f9d57abc60545399fd9b0a3', + revision = '25a7c617192253bddfa65e378975d8c476419010', url = 'https://github.com/uncenter/tree-sitter-tera', }, maintainers = { '@uncenter' }, @@ -2306,7 +2306,7 @@ return { terraform = { install_info = { location = 'dialects/terraform', - revision = '9e3ec9848f28d26845ba300fd73c740459b83e9b', + revision = 'de10d494dbd6b71cdf07a678fecbf404dbfe4398', url = 'https://github.com/MichaHoffmann/tree-sitter-hcl', }, maintainers = { '@MichaHoffmann' }, @@ -2525,7 +2525,7 @@ return { }, vhs = { install_info = { - revision = '3f202326c06f1c4d47aa82b9013a6b71aea70611', + revision = '0c6fae9d2cfc5b217bfd1fe84a7678f5917116db', url = 'https://github.com/charmbracelet/tree-sitter-vhs', }, maintainers = { '@caarlos0' }, |
