From 2aa86a1bbe58c1f82f07a04fa68fdf0a4bc5ef5a Mon Sep 17 00:00:00 2001 From: Oleksandr Smirnov Date: Fri, 28 Feb 2025 15:08:27 +0200 Subject: [PATCH] refactor(installer)!: add sync as an option --- lua/gopher/installer.lua | 13 +++++++------ plugin/gopher.vim | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lua/gopher/installer.lua b/lua/gopher/installer.lua index ee75344..526e688 100644 --- a/lua/gopher/installer.lua +++ b/lua/gopher/installer.lua @@ -37,14 +37,15 @@ local function install_sync(url) end ---Install required go deps ----@param sync? boolean -function installer.install_deps(sync) - sync = sync or false +---@param opts? {sync:boolean} +function installer.install_deps(opts) + opts = opts or {} for pkg, _ in pairs(urls) do - if sync then - install_sync(urls[pkg] .. "@latest") + local url = urls[pkg] .. "@latest" + if opts.sync then + install_sync(url) else - install(urls[pkg] .. "@latest") + install(url) end end end diff --git a/plugin/gopher.vim b/plugin/gopher.vim index d458849..b61ed6e 100644 --- a/plugin/gopher.vim +++ b/plugin/gopher.vim @@ -11,5 +11,5 @@ command! -nargs=* GoGenerate :lua require"gopher".generate() command! GoCmt :lua require"gopher".comment() command! GoIfErr :lua require"gopher".iferr() command! GoInstallDeps :lua require"gopher".install_deps() -command! GoInstallDepsSync :lua require"gopher".install_deps(true) +command! GoInstallDepsSync :lua require"gopher".install_deps({ sync = true }) command! GopherLog :lua vim.cmd("tabnew " .. require("gopher._utils.log").get_outfile())