From 932c0aa0c334ad384e2a1368d53f49bf52a4f80d Mon Sep 17 00:00:00 2001 From: Smirnov Olexander Date: Fri, 17 Jun 2022 22:32:41 +0300 Subject: [PATCH] refactor(installer): return function instead of M --- lua/gopher/init.lua | 2 +- lua/gopher/installer.lua | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lua/gopher/init.lua b/lua/gopher/init.lua index 3ada8c4..3af5005 100644 --- a/lua/gopher/init.lua +++ b/lua/gopher/init.lua @@ -1,7 +1,7 @@ local tags = require "gopher.struct_tags" local gopher = {} -gopher.install_deps = require("gopher.installer").install_all +gopher.install_deps = require "gopher.installer" gopher.tags_add = tags.add gopher.tags_rm = tags.remove gopher.mod = require "gopher.gomod" diff --git a/lua/gopher/installer.lua b/lua/gopher/installer.lua index 6e0bd87..b0f733a 100644 --- a/lua/gopher/installer.lua +++ b/lua/gopher/installer.lua @@ -1,13 +1,11 @@ local Job = require "plenary.job" -local M = { - urls = { - gomodifytags = "github.com/fatih/gomodifytags", - impl = "github.com/josharian/impl", - }, +local urls = { + gomodifytags = "github.com/fatih/gomodifytags", + impl = "github.com/josharian/impl", } local function install(pkg) - local url = M.urls[pkg] .. "@latest" + local url = urls[pkg] .. "@latest" Job :new({ @@ -26,10 +24,8 @@ local function install(pkg) end ---Install required go deps -function M.install_all() - for pkg, _ in pairs(M.urls) do +return function() + for pkg, _ in pairs(urls) do install(pkg) end end - -return M