mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 17:30:08 -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 luv = vim.loop
|
||||||
local configs = require'nvim-treesitter/configs'
|
local configs = require'nvim-treesitter/configs'
|
||||||
local parsers = configs.get_parser_configs()
|
local parsers = configs.get_parser_configs()
|
||||||
|
local has_parser = require'nvim-treesitter/parsers'.has_parser
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
@ -143,6 +144,24 @@ local function install(ft)
|
||||||
run_install(cache_folder, package_path, ft, install_info)
|
run_install(cache_folder, package_path, ft, install_info)
|
||||||
end
|
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 = {
|
M.commands = {
|
||||||
TSInstall = {
|
TSInstall = {
|
||||||
run = install,
|
run = install,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue