diff options
author | Gustaf Rydholm <gustaf@nexure.io> | 2022-10-17 09:00:28 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf@nexure.io> | 2022-10-17 09:00:28 +0200 |
commit | f9c022399a35558fe7f997dbeab3c26d7f955992 (patch) | |
tree | 30dfed56d752ff779da584ab502e9a3bda952215 /fnl/util.fnl | |
parent | a45853f468feb2be399a587664df7f4872816b53 (diff) | |
parent | f3432fc8f42246ac26f90146f13045377bc3899e (diff) |
Merge branch 'master' of github.com:aktersnurra/nvim
Diffstat (limited to 'fnl/util.fnl')
-rw-r--r-- | fnl/util.fnl | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/fnl/util.fnl b/fnl/util.fnl deleted file mode 100644 index 88ec1c3..0000000 --- a/fnl/util.fnl +++ /dev/null @@ -1,43 +0,0 @@ -;; Utility functions. -(module util {autoload {a aniseed.core nvim aniseed.nvim : packer}}) - -(def- path (.. (vim.fn.stdpath :data) :/site/pack/packer/start)) - -(def- installed-plugins (vim.fn.readdir path)) - -(def- configured-plugins (require :plugins)) - -(defn- parse-plugins-names [plugins] (var names []) - (each [plugin _ (pairs plugins)] - (table.insert names (string.match plugin "/(.*)"))) names) - -(defn- contains [ys xs] (var equal true) - (each [_ x (pairs xs)] - (if (not= (vim.tbl_contains ys x) true) - (set equal false))) equal) - -(defn- deep-equal [xs ys] (and (contains xs ys) (contains ys xs))) - -(defn- synchronized [configured installed] (deep-equal configured installed)) - -(defn- install [] - (packer.startup (fn [use] - (each [plugin opts (pairs configured-plugins)] - (use (a.assoc opts 1 plugin)))))) - -(defn load-plugins [] (install) - (if (not= (synchronized (parse-plugins-names configured-plugins) - installed-plugins) true) - (packer.sync) - (require :config))) - -(defn load-plugin [name] - (let [(ok? plugin) (pcall require name)] - (if ok? - plugin - (vim.notify (.. "Could not load config: " val-or-err) - vim.log.levels.WARN)))) - -(defn use-config [plugin config] - (let [plugin (load-plugin plugin)] - (plugin.setup config))) |