(fn str? [x] (= :string (type x))) (fn nil? [x] (= nil x)) (fn tbl? [x] (= :table (type x))) (local {: insert} table) (global nvrc/pack []) (lambda pack [identifier ?options] "Returns a mixed table with the identifier as the first sequential element and options as hash-table items. See https://github.com/folke/lazy.nvim for information about the options." (assert-compile (str? identifier) "expected string for identifier" identifier) (assert-compile (or (nil? ?options) (tbl? ?options)) "expected table for options" ?options) (let [options (or ?options {}) options (collect [k v (pairs options)] (if (= k :req) (values :config `#(require (string.format "nvrc.packs.%s" ,v))) (= k :init) (values :config `#((. (require ,v) :setup))) (values k v)))] (doto options (tset 1 identifier)))) (lambda pack! [identifier ?options] "Declares a plugin with its options. This is a mixed table saved on the global compile-time variable nvrc/pack. See https://github.com/folke/lazy.nvim for information about the options." (assert-compile (str? identifier) "expected string for identifier" identifier) (assert-compile (or (nil? ?options) (tbl? ?options)) "expected table for options" ?options) (insert nvrc/pack (pack identifier ?options))) (lambda unpack! [] "Initializes the plugin manager with the previously declared plugins and their options." (let [packs [(unpack (icollect [_ v (ipairs nvrc/pack)] v))]] `((. (require :lazy) :setup) ,packs))) {: pack : pack! : unpack!}