mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -04:00
install can take 'all' as parameter
This commit is contained in:
parent
5e91955b6a
commit
3e4ea3d890
1 changed files with 14 additions and 12 deletions
|
|
@ -95,11 +95,20 @@ local function install(...)
|
||||||
local cache_folder, err = utils.get_cache_dir()
|
local cache_folder, err = utils.get_cache_dir()
|
||||||
if err then return api.nvim_err_writeln(err) end
|
if err then return api.nvim_err_writeln(err) end
|
||||||
|
|
||||||
for _, lang in ipairs({ ... }) do
|
local languages = { ... }
|
||||||
if #api.nvim_get_runtime_file('parser/'..lang..'.so', false) > 0 then
|
local check_installed = true
|
||||||
local yesno = fn.input(lang .. ' parser already available: would you like to reinstall ? y/n: ')
|
if ... == 'all' then
|
||||||
print('\n ') -- mandatory to avoid messing up command line
|
languages = parsers.available_parsers()
|
||||||
if not string.match(yesno, '^y.*') then return end
|
check_installed = false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, lang in ipairs(languages) do
|
||||||
|
if check_installed then
|
||||||
|
if #api.nvim_get_runtime_file('parser/'..lang..'.so', false) > 0 then
|
||||||
|
local yesno = fn.input(lang .. ' parser already available: would you like to reinstall ? y/n: ')
|
||||||
|
print('\n ') -- mandatory to avoid messing up command line
|
||||||
|
if not string.match(yesno, '^y.*') then return end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local parser_config = parsers.get_parser_configs()[lang]
|
local parser_config = parsers.get_parser_configs()[lang]
|
||||||
|
|
@ -143,13 +152,6 @@ M.commands = {
|
||||||
"-complete=custom,v:lua.ts_installable_parsers"
|
"-complete=custom,v:lua.ts_installable_parsers"
|
||||||
},
|
},
|
||||||
description = '`:TSInstall {lang}` installs a parser under nvim-treesitter/parser/{lang}.so'
|
description = '`:TSInstall {lang}` installs a parser under nvim-treesitter/parser/{lang}.so'
|
||||||
},
|
|
||||||
TSInstallAll = {
|
|
||||||
run = function()
|
|
||||||
for _, lang in pairs(parsers.available_parsers()) do
|
|
||||||
install(lang)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue