diff options
| author | kiyan42 <yazdani.kiyan@protonmail.com> | 2020-06-25 12:37:01 +0200 |
|---|---|---|
| committer | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-06-25 13:52:29 +0200 |
| commit | 3e4ea3d890d3914d1fe56b21363308470c700678 (patch) | |
| tree | 5756af4e0ac3dde8d38b884cae1aee9aff294ab3 /lua | |
| parent | add command to install all parsers (diff) | |
| download | nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.tar nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.tar.gz nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.tar.bz2 nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.tar.lz nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.tar.xz nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.tar.zst nvim-treesitter-3e4ea3d890d3914d1fe56b21363308470c700678.zip | |
install can take 'all' as parameter
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 2a9257f73..24f6fbd63 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -95,11 +95,20 @@ local function install(...) local cache_folder, err = utils.get_cache_dir() if err then return api.nvim_err_writeln(err) end - for _, lang in ipairs({ ... }) do - 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 + local languages = { ... } + local check_installed = true + if ... == 'all' then + languages = parsers.available_parsers() + 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 local parser_config = parsers.get_parser_configs()[lang] @@ -143,13 +152,6 @@ M.commands = { "-complete=custom,v:lua.ts_installable_parsers" }, 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 } } |
