diff options
-rw-r--r-- | fnl/init.fnl | 4 | ||||
-rw-r--r-- | fnl/util.fnl | 28 |
2 files changed, 15 insertions, 17 deletions
diff --git a/fnl/init.fnl b/fnl/init.fnl index dd6d1b0..ce1c84f 100644 --- a/fnl/init.fnl +++ b/fnl/init.fnl @@ -1,6 +1,4 @@ ;; Install, load settings, and load plugin configs. (module init {autoload {util util} require [settings config.packer]}) -(util.install) -(util.sync) -(util.load-config) +(util.load-plugins) diff --git a/fnl/util.fnl b/fnl/util.fnl index a27d0bf..d1b3665 100644 --- a/fnl/util.fnl +++ b/fnl/util.fnl @@ -4,25 +4,25 @@ packer packer plugins plugins}}) -(var num-plugins 0) - (def- path (.. (vim.fn.stdpath :data) :/site/pack/packer/start)) -(defn- num-installed-plugins [] (length (vim.fn.readdir path))) +(defn- num-plugins [] (var i 0) + (each [_ _ (pairs plugins.plugins)] + (set i (+ i 1))) i) -(defn sync [] (let [num-installed-plugins (num-installed-plugins)] - (if (not= num-installed-plugins num-plugins) - (packer.sync)))) +(defn- num-installed-plugins [] (length (vim.fn.readdir path))) -(defn install [] - (packer.startup (fn [use] - (each [plugin opts (pairs plugins.plugins)] - (set num-plugins (+ num-plugins 1)) - (use (a.assoc opts 1 plugin)))))) +(defn- install [] + (packer.startup (fn [use] + (each [plugin opts (pairs plugins.plugins)] + (use (a.assoc opts 1 plugin)))))) -(defn load-config [] (let [num-installed-plugins (num-installed-plugins)] - (if (= num-installed-plugins num-plugins) - (require :config)))) +(defn load-plugins [] (install) + (let [num-installed-plugins (num-installed-plugins) + num-plugins (num-plugins)] + (if (= num-installed-plugins num-plugins) + (require :config) + (packer.sync)))) (defn load-plugin [name] (let [(ok? val-or-err) (pcall require name)] |