diff options
| author | Stephan Seitz <sseitz@nvidia.com> | 2021-10-01 18:18:11 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-10-01 22:21:16 +0200 |
| commit | 2a073f760caf6b1611ce39815d2fdf66c6967147 (patch) | |
| tree | 8f9fdbe95c891c9ca48bfc04a239fa53b613c003 /lua | |
| parent | Rust: fix some highlights (diff) | |
| download | nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.tar nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.tar.gz nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.tar.bz2 nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.tar.lz nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.tar.xz nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.tar.zst nvim-treesitter-2a073f760caf6b1611ce39815d2fdf66c6967147.zip | |
feat(install): add options `prefer_git` and `command_extra_args`
Fixes #1888
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 14 | ||||
| -rw-r--r-- | lua/nvim-treesitter/shell_command_selectors.lua | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 01bfef4d6..c0f85e9f8 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -12,6 +12,8 @@ local M = {} local lockfile = {} M.compilers = { vim.fn.getenv "CC", "cc", "gcc", "clang", "cl" } +M.prefer_git = fn.has "win32" == 1 +M.command_extra_args = {} local started_commands = 0 local finished_commands = 0 @@ -124,6 +126,10 @@ function M.iter_cmd(cmd_list, i, lang, success_message) print(get_job_status() .. " " .. attr.info) end + if attr.opts and attr.opts.args and M.command_extra_args[attr.cmd] then + vim.list_extend(attr.opts.args, M.command_extra_args[attr.cmd]) + end + if type(attr.cmd) == "function" then local ok, err = pcall(attr.cmd) if ok then @@ -180,6 +186,9 @@ end local function get_command(cmd) local options = "" if cmd.opts and cmd.opts.args then + if M.command_extra_args[cmd.cmd] then + vim.list_extend(cmd.opts.args, M.command_extra_args[cmd.cmd]) + end for _, opt in ipairs(cmd.opts.args) do options = string.format("%s %s", options, opt) end @@ -270,7 +279,10 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, local command_list = {} if not from_local_path then vim.list_extend(command_list, { shell.select_install_rm_cmd(cache_folder, project_name) }) - vim.list_extend(command_list, shell.select_download_commands(repo, project_name, cache_folder, revision)) + vim.list_extend( + command_list, + shell.select_download_commands(repo, project_name, cache_folder, revision, M.prefer_git) + ) end if generate_from_grammar then if repo.generate_requires_npm then diff --git a/lua/nvim-treesitter/shell_command_selectors.lua b/lua/nvim-treesitter/shell_command_selectors.lua index fe7273962..7acd91d2f 100644 --- a/lua/nvim-treesitter/shell_command_selectors.lua +++ b/lua/nvim-treesitter/shell_command_selectors.lua @@ -121,16 +121,14 @@ function M.select_mv_cmd(from, to, cwd) end end -function M.select_download_commands(repo, project_name, cache_folder, revision) +function M.select_download_commands(repo, project_name, cache_folder, revision, prefer_git) local can_use_tar = vim.fn.executable "tar" == 1 and vim.fn.executable "curl" == 1 local is_github = repo.url:find("github.com", 1, true) local is_gitlab = repo.url:find("gitlab.com", 1, true) - local is_windows = fn.has "win32" == 1 - revision = revision or repo.branch or "master" - if can_use_tar and (is_github or is_gitlab) and not is_windows then + if can_use_tar and (is_github or is_gitlab) and not prefer_git then local path_sep = utils.get_path_sep() local url = repo.url:gsub(".git$", "") |
