aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorkiyan42 <yazdani.kiyan@protonmail.com>2020-06-29 16:16:18 +0200
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-06-30 08:32:49 +0200
commit2a20484a1454d7ba91644b00505df1f4457b94d6 (patch)
tree11ea4e1c8a4a545b8966869db71e9179ecc7f9e9 /lua
parentupdate installer with sync and some fixes (diff)
downloadnvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.tar
nvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.tar.gz
nvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.tar.bz2
nvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.tar.lz
nvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.tar.xz
nvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.tar.zst
nvim-treesitter-2a20484a1454d7ba91644b00505df1f4457b94d6.zip
fix: remove goto statements
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/install.lua45
1 files changed, 24 insertions, 21 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index e91987120..3805750b4 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -120,6 +120,29 @@ local function run_install(cache_folder, package_path, lang, repo, with_sync)
end
end
+local function install_lang(lang, ask_reinstall, cache_folder, package_path, with_sync)
+ if #api.nvim_get_runtime_file('parser/'..lang..'.so', false) > 0 then
+ if not ask_reinstall then return end
+
+ 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
+
+ local parser_config = parsers.get_parser_configs()[lang]
+ if not parser_config then
+ return api.nvim_err_writeln('Parser not available for language '..lang)
+ end
+
+ local install_info = parser_config.install_info
+ vim.validate {
+ url={ install_info.url, 'string' },
+ files={ install_info.files, 'table' }
+ }
+
+ run_install(cache_folder, package_path, lang, install_info, with_sync)
+end
+
-- TODO(kyazdani): this should work on windows too
local function install(with_sync)
return function (...)
@@ -145,27 +168,7 @@ local function install(with_sync)
end
for _, lang in ipairs(languages) do
- if #api.nvim_get_runtime_file('parser/'..lang..'.so', false) > 0 then
- if not ask_reinstall then goto continue end
-
- 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 goto continue end
- end
-
- local parser_config = parsers.get_parser_configs()[lang]
- if not parser_config then
- return api.nvim_err_writeln('Parser not available for language '..lang)
- end
-
- local install_info = parser_config.install_info
- vim.validate {
- url={ install_info.url, 'string' },
- files={ install_info.files, 'table' }
- }
-
- run_install(cache_folder, package_path, lang, install_info, with_sync)
- ::continue::
+ install_lang(lang, ask_reinstall, cache_folder, package_path, with_sync)
end
end
end