diff options
| author | Suhas Hebbar <suhas.shripad.hebbar@gmail.com> | 2020-10-05 21:42:17 +0530 |
|---|---|---|
| committer | Kiyan Yazdani <yazdani.kiyan@protonmail.com> | 2020-10-06 19:08:42 +0200 |
| commit | 40edefc476d72ae999f0678ce1577adcb5ee085c (patch) | |
| tree | ec0703ebaf17bfae0d0fda80516b8914f738fcc4 | |
| parent | Fix typearg brackets not highlighting for multiple typeargs (diff) | |
| download | nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.tar nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.tar.gz nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.tar.bz2 nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.tar.lz nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.tar.xz nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.tar.zst nvim-treesitter-40edefc476d72ae999f0678ce1577adcb5ee085c.zip | |
Remove dependency on unzip.
Use tar instead which should be available on default Unixes and Windows
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 3f9125c34..1069cae97 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -37,6 +37,30 @@ local function get_revision(lang) return (lockfile[lang] and lockfile[lang].revision) end +local function select_mkdir_cmd(directory, cwd, info_msg) + if fn.has('win32') == 1 then + return { + cmd = 'cmd', + opts = { + args = { '/C', 'mkdir', directory}, + cwd = cwd, + }, + info = info_msg, + err = "Could not create "..directory, + } + else + return { + cmd = 'mkdir', + opts = { + args = { directory }, + cwd = cwd, + }, + info = info_msg, + err = "Could not create "..directory, + } + end +end + local function select_rm_file_cmd(file, info_msg) if fn.has('win32') == 1 then return { @@ -182,7 +206,7 @@ local function select_mv_cmd(from, to, cwd) end local function select_download_commands(repo, project_name, cache_folder, revision) - if vim.fn.executable('unzip') == 1 and vim.fn.executable('curl') == 1 and repo.url:find("github.com", 1, true) then + if vim.fn.executable('tar') == 1 and vim.fn.executable('curl') == 1 and repo.url:find("github.com", 1, true) then revision = revision or repo.branch or "master" local path_sep = utils.get_path_sep() @@ -195,28 +219,29 @@ local function select_download_commands(repo, project_name, cache_folder, revisi opts = { args = { '-L', -- follow redirects - repo.url.."/archive/"..revision..".zip", + repo.url.."/archive/"..revision..".tar.gz", '--output', - project_name..".zip" + project_name..".tar.gz" }, cwd = cache_folder, }, }, + select_mkdir_cmd(project_name..'-tmp', cache_folder, 'Creating temporary directory'), { - cmd = 'unzip', + cmd = 'tar', info = 'Extracting...', - err = 'Error during unzipping', + err = 'Error during tarball extraction.', opts = { args = { - '-o', - project_name..".zip", - '-d', + '-xvf', + project_name..".tar.gz", + '-C', project_name..'-tmp', }, cwd = cache_folder, }, }, - select_rm_file_cmd(cache_folder..path_sep..project_name..".zip"), + select_rm_file_cmd(cache_folder..path_sep..project_name..".tar.gz"), select_mv_cmd(utils.join_path(project_name..'-tmp', repo.url:match('[^/]-$')..'-'..revision), project_name, cache_folder), |
