diff options
| -rw-r--r-- | doc/nvim-treesitter.txt | 21 | ||||
| -rw-r--r-- | lua/nvim-treesitter/config.lua | 8 | ||||
| -rw-r--r-- | lua/nvim-treesitter/health.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/init.lua | 8 | ||||
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 4 | ||||
| -rw-r--r-- | plugin/nvim-treesitter.lua | 2 | ||||
| -rwxr-xr-x | scripts/check-parsers.lua | 2 | ||||
| -rwxr-xr-x | scripts/check-queries.lua | 2 |
8 files changed, 36 insertions, 13 deletions
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index 77e6f037f..9ba6909b7 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -102,7 +102,7 @@ setup({opts}) *nvim-treesitter.setup()* directory to install parsers and queries to. Note: will be prepended to |runtimepath|. -install({languages} [, {opts}]) *nvim-treesitter.install()* +install({languages} [, {opts}]) *nvim-treesitter.install()* Download, compile, and install the specified treesitter parsers and copy the corresponding queries to a directory on |runtimepath|, enabling their @@ -126,7 +126,7 @@ install({languages} [, {opts}]) *nvim-treesitter.install()* • {max_jobs} (`integer?`) limit parallel tasks (useful in combination with {generate} on memory-limited systems). -uninstall({languages}) *nvim-treesitter.uninstall()* +uninstall({languages}) *nvim-treesitter.uninstall()* Remove the parser and queries for the specified language(s). @@ -134,7 +134,7 @@ uninstall({languages}) *nvim-treesitter.uninstall() • {languages} `(string[]|string)` (List of) languages or tiers (`stable`, `unstable`) to update. -update([{languages}]) *nvim-treesitter.update()* +update([{languages}]) *nvim-treesitter.update()* Update the parsers and queries if older than the revision specified in the manifest. @@ -153,5 +153,20 @@ indentexpr() *nvim-treesitter.indentexpr()* Used to enable treesitter indentation for a language via >lua vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" < +get_available([{tier}]) *nvim-treesitter.get_available()* + + Return list of languages available for installation. + + Parameters: ~ + • {tier} `(integer?)` Only return languages of specified {tier} (`1`: + stable, `2`: unstable, `3`: unmaintained, `4`: unsupported) + +get_installed([{type}]) *nvim-treesitter.get_installed()* + + Return list of languages installed via `nvim-treesitter`. + + Parameters: ~ + • {type} `('queries'|parsers'?)` If specified, only show languages with + installed queries or parsers, respectively. vim:tw=78:ts=8:expandtab:noet:ft=help:norl: diff --git a/lua/nvim-treesitter/config.lua b/lua/nvim-treesitter/config.lua index e46e2d5d1..1a5b56cdb 100644 --- a/lua/nvim-treesitter/config.lua +++ b/lua/nvim-treesitter/config.lua @@ -41,7 +41,7 @@ end ---@param type 'queries'|'parsers'? ---@return string[] -function M.installed_languages(type) +function M.get_installed(type) local installed = {} --- @type table<string, boolean> if not (type and type == 'parsers') then for f in vim.fs.dir(M.get_install_dir('queries')) do @@ -107,7 +107,7 @@ function M.norm_languages(languages, skip) if vim.list_contains(languages, 'all') then if skip and skip.missing then - return M.installed_languages() + return M.get_installed() end languages = M.get_available() end @@ -115,7 +115,7 @@ function M.norm_languages(languages, skip) languages = expand_tiers(languages) if skip and skip.installed then - local installed = M.installed_languages() + local installed = M.get_installed() languages = vim.tbl_filter( --- @param v string function(v) @@ -126,7 +126,7 @@ function M.norm_languages(languages, skip) end if skip and skip.missing then - local installed = M.installed_languages() + local installed = M.get_installed() languages = vim.tbl_filter( --- @param v string function(v) diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index 4095bce00..3f5058996 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -136,7 +136,7 @@ function M.check() -- Parser installation checks health.start('Installed languages' .. string.rep(' ', 5) .. 'H L F I J') - local languages = config.installed_languages() + local languages = config.get_installed() for _, lang in pairs(languages) do local parser = parsers[lang] local out = lang .. string.rep(' ', 22 - #lang) diff --git a/lua/nvim-treesitter/init.lua b/lua/nvim-treesitter/init.lua index 561c1697a..c5a9201f3 100644 --- a/lua/nvim-treesitter/init.lua +++ b/lua/nvim-treesitter/init.lua @@ -4,6 +4,14 @@ function M.setup(...) require('nvim-treesitter.config').setup(...) end +function M.get_available(...) + return require('nvim-treesitter.config').get_available(...) +end + +function M.get_installed(...) + return require('nvim-treesitter.config').get_installed(...) +end + function M.install(...) return require('nvim-treesitter.install').install(...) end diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 6391beba9..eb55d0191 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -402,7 +402,7 @@ local install_status = {} ---@type table<string,InstallStatus?> ---@param generate? boolean ---@return InstallStatus status local function install_lang(lang, cache_dir, install_dir, force, generate) - if not force and vim.list_contains(config.installed_languages(), lang) then + if not force and vim.list_contains(config.get_installed(), lang) then install_status[lang] = 'installed' return 'installed' end @@ -537,7 +537,7 @@ M.uninstall = a.async(function(languages) local parser_dir = config.get_install_dir('parser') local query_dir = config.get_install_dir('queries') - local installed = config.installed_languages() + local installed = config.get_installed() local task_funs = {} ---@type async.TaskFun[] local done = 0 diff --git a/plugin/nvim-treesitter.lua b/plugin/nvim-treesitter.lua index d4ccf3049..8bf2dbfde 100644 --- a/plugin/nvim-treesitter.lua +++ b/plugin/nvim-treesitter.lua @@ -21,7 +21,7 @@ local function complete_installed_parsers(arglead) function(v) return v:find(arglead) ~= nil end, - require('nvim-treesitter.config').installed_languages() + require('nvim-treesitter.config').get_installed() ) end diff --git a/scripts/check-parsers.lua b/scripts/check-parsers.lua index 152c8f7ea..c2eefd7c9 100755 --- a/scripts/check-parsers.lua +++ b/scripts/check-parsers.lua @@ -3,7 +3,7 @@ vim.opt.runtimepath:append('.') local configs = require('nvim-treesitter.parsers') local parsers = #_G.arg > 0 and { unpack(_G.arg) } - or require('nvim-treesitter.config').installed_languages('parsers') + or require('nvim-treesitter.config').get_installed('parsers') local data = {} ---@type table[] local errors = {} ---@type string[] diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua index 27869b6b5..796e3f5fc 100755 --- a/scripts/check-queries.lua +++ b/scripts/check-queries.lua @@ -4,7 +4,7 @@ vim.opt.runtimepath:append('.') local query_types = require('nvim-treesitter.health').bundled_queries local configs = require('nvim-treesitter.parsers') local parsers = #_G.arg > 0 and { unpack(_G.arg) } - or require('nvim-treesitter.config').installed_languages('queries') + or require('nvim-treesitter.config').get_installed('queries') -- Check queries for each installed parser in parsers local errors = {} ---@type string[] |
