summaryrefslogtreecommitdiff
path: root/fnl/util.fnl
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-06-02 00:00:30 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-06-02 00:00:30 +0200
commit62534c1e62ec403b798c5e8f657169bc6f965449 (patch)
treed3e0fac2a1a10dadee7ee49123919ef7d34bf1cc /fnl/util.fnl
parent778f0d4fc6157a960f0efe90bc6dc535794efb1c (diff)
Convert utils to pure fns
Diffstat (limited to 'fnl/util.fnl')
-rw-r--r--fnl/util.fnl28
1 files changed, 14 insertions, 14 deletions
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)]