blob: 5ba78962b63b33be9497022f1bd7a40d44ffbaec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
(fn str? [x]
(= :string (type x)))
(fn nil? [x]
(= nil x))
(fn tbl? [x]
(= :table (type x)))
(local {: format} string)
(local {: insert} table)
(global nvrc/pack [])
(global nvrc/rock [])
(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/wbthomason/packer.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 (format "require('nvrc.packs.%s')" v))
(= k :init) (values :config (format "require('%s').setup()" v))
(= k :defer) (values :setup (format "require('nvrc.utils').defer_unpack('%s', 5)" v))
(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/wbthomason/packer.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 rock [identifier ?options]
"Returns a mixed table with the identifier as the first sequential element
and options as hash-table items.
See https://github.com/wbthomason/packer.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 {})]
(doto options
(tset 1 identifier))))
(lambda rock! [identifier ?options]
"Declares a plugin with its options.
This is a mixed table saved on the global compile-time variable nvrc/rock.
See https://github.com/wbthomason/packer.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/rock (rock identifier ?options)))
(lambda unpack! []
"Initializes the plugin manager with the previously declared plugins and
their options."
(let [packs (icollect [_ v (ipairs nvrc/pack)]
`(use ,v))
rocks (icollect [_ v (ipairs nvrc/rock)]
`(use_rocks ,v))]
`((. (require :packer) :startup) #(do
,(unpack (icollect [_ v (ipairs packs) :into rocks] v))))))
{: pack
: pack!
: rock
: rock!
: unpack!}
|