-
Notifications
You must be signed in to change notification settings - Fork 38
/
sources.clj
26 lines (21 loc) · 803 Bytes
/
sources.clj
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
(ns compliment.sources
"Tools for defining sources for the completion.")
(def ^{:doc "Stores defined sources."
:private true}
sources (atom nil))
(defn all-sources
"Returns the list of all completion sources, or the selected once specified by
`source-kws`."
([] @sources)
([source-kws]
(select-keys @sources source-kws)))
(defn defsource
"Defines a source with the given name and argument map. Map must
contain two keys - `:candidates` and `:doc`.
Value of `:candidates`should be a function of prefix, namespace and
context.
Value of `:doc` latter should be a function of symbol name and
namespace."
[name & {:as kw-args}]
{:pre [^{:lite '(:candidates kw-args)} (every? kw-args [:candidates :doc])]}
(swap! sources assoc name (assoc kw-args :enabled true)))