Skip to content

Commit 5163b70

Browse files
committed
Change keyword-groups to a map
1 parent 204fe33 commit 5163b70

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

clj/src/vim_clojure_static/generate.clj

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,18 @@
103103
monitor-enter monitor-exit . new set!})
104104

105105
(def keyword-groups
106-
"Special forms, constants, and every public var in clojure.core listed by
107-
syntax group suffix."
108-
(let [builtins [["clojureConstant" '#{nil}]
109-
["clojureBoolean" '#{true false}]
110-
["clojureSpecial" special-forms]
106+
"Special forms, constants, and every public var in clojure.core keyed by
107+
syntax group name."
108+
(let [builtins {"clojureConstant" '#{nil}
109+
"clojureBoolean" '#{true false}
110+
"clojureSpecial" special-forms
111111
;; These are duplicates from special-forms
112-
["clojureException" '#{throw try catch finally}]
113-
["clojureCond" '#{case cond cond-> cond->> condp if-let
114-
if-not if-some when when-first when-let
115-
when-not when-some}]
112+
"clojureException" '#{throw try catch finally}
113+
"clojureCond" '#{case cond cond-> cond->> condp if-let
114+
if-not if-some when when-first when-let
115+
when-not when-some}
116116
;; Imperative looping constructs (not sequence functions)
117-
["clojureRepeat" '#{doseq dotimes while}]]
117+
"clojureRepeat" '#{doseq dotimes while}}
118118
coresyms (set/difference (set (keys (ns-publics 'clojure.core)))
119119
(set (mapcat peek builtins)))
120120
group-preds [["clojureDefine" #(re-seq #"\Adef(?!ault)" (str %))]
@@ -123,9 +123,9 @@
123123
["clojureVariable" identity]]]
124124
(first
125125
(reduce
126-
(fn [[v syms] [group pred]]
126+
(fn [[m syms] [group pred]]
127127
(let [group-syms (set (filterv pred syms))]
128-
[(conj v [group group-syms])
128+
[(assoc m group group-syms)
129129
(set/difference syms group-syms)]))
130130
[builtins coresyms] group-preds))))
131131

@@ -134,7 +134,7 @@
134134
(let [props (->> (get-private-field Pattern$CharPropertyNames "map")
135135
(mapv (fn [[prop field]] [(inner-class-name (class field)) prop]))
136136
(group-by first)
137-
(reduce (fn [m [k v]] (assoc m k (mapv peek v))) {}))
137+
(reduce-kv (fn [m k v] (assoc m k (mapv peek v))) {}))
138138
binary (concat (map #(.name ^UnicodeProp %) (get-private-field UnicodeProp "$VALUES"))
139139
(keys (get-private-field UnicodeProp "aliases")))
140140
script (concat (map #(.name ^Character$UnicodeScript %) (Character$UnicodeScript/values))
@@ -183,6 +183,7 @@
183183
(def vim-keywords
184184
"Vimscript literal dictionary of important identifiers."
185185
(->> keyword-groups
186+
sort
186187
(map (fn [[group keywords]]
187188
(->> keywords
188189
map-keyword-names
@@ -344,7 +345,7 @@
344345
vim-unicode-block-char-classes)
345346
"-*- TOP CLUSTER -*-"
346347
(qstr generation-comment
347-
(vim-top-cluster (mapv first keyword-groups)
348+
(vim-top-cluster (keys keyword-groups)
348349
(slurp (fjoin dir "syntax/clojure.vim"))))}
349350

350351
(fjoin dir "ftplugin/clojure.vim")

0 commit comments

Comments
 (0)