mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Add function 'nvim-treesitter/install'.ensure_installed
This commit is contained in:
parent
5532019122
commit
6b2d76153f
1 changed files with 19 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ local fn = vim.fn
|
|||
local luv = vim.loop
|
||||
local configs = require'nvim-treesitter/configs'
|
||||
local parsers = configs.get_parser_configs()
|
||||
local has_parser = require'nvim-treesitter/parsers'.has_parser
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
@ -143,6 +144,24 @@ local function install(ft)
|
|||
run_install(cache_folder, package_path, ft, install_info)
|
||||
end
|
||||
|
||||
|
||||
M.ensure_installed = function(languages)
|
||||
if type(languages) == 'string' then
|
||||
if languages == 'all' then
|
||||
languages = configs.available_parsers()
|
||||
else
|
||||
languages = {languages}
|
||||
end
|
||||
end
|
||||
|
||||
for _, ft in ipairs(languages) do
|
||||
if not has_parser(ft) then
|
||||
install(ft)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
M.commands = {
|
||||
TSInstall = {
|
||||
run = install,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue