22Language: Clojure
33Description: Clojure syntax (based on lisp.js)
44Author: mfornos
5- Contributors: Martin Clausen <[email protected] > 65Website: https://clojure.org
76Category: lisp
87*/
98
109export default function ( hljs ) {
10+ var globals = 'def defonce defprotocol defstruct defmulti defmethod defn- defn defmacro deftype defrecord' ;
1111 var keywords = {
1212 'builtin-name' :
1313 // Clojure keywords
14- 'def defonce cond apply if-not if-let if not not= = < > <= >= == + / * - rem ' +
15- 'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? ' +
16- 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? ' +
17- 'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? ' +
18- 'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . ' +
19- 'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last ' +
20- 'drop-while while intern condp case reduced cycle split-at split-with repeat replicate ' +
21- 'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext ' +
22- 'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends ' +
23- 'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler ' +
24- 'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter ' +
25- 'monitor-exit defmacro defn defn- macroexpand macroexpand-1 for dosync and or ' +
26- 'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert ' +
27- 'peek pop doto proxy defstruct first rest cons defprotocol cast coll deftype defrecord last butlast ' +
28- 'sigs reify second ffirst fnext nfirst nnext defmulti defmethod meta with-meta ns in-ns create-ns import ' +
29- 'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! ' +
30- 'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger ' +
31- 'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline ' +
32- 'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking ' +
33- 'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! ' +
34- 'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! ' +
35- 'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty ' +
36- 'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list ' +
37- 'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer ' +
38- 'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate ' +
39- 'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta ' +
14+ globals + ' ' +
15+ 'cond apply if-not if-let if not not= = < > <= >= == + / * - rem ' +
16+ 'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? ' +
17+ 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? ' +
18+ 'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? ' +
19+ 'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . ' +
20+ 'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last ' +
21+ 'drop-while while intern condp case reduced cycle split-at split-with repeat replicate ' +
22+ 'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext ' +
23+ 'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends ' +
24+ 'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler ' +
25+ 'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter ' +
26+ 'monitor-exit macroexpand macroexpand-1 for dosync and or ' +
27+ 'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert ' +
28+ 'peek pop doto proxy first rest cons cast coll last butlast ' +
29+ 'sigs reify second ffirst fnext nfirst nnext meta with-meta ns in-ns create-ns import ' +
30+ 'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! ' +
31+ 'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger ' +
32+ 'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline ' +
33+ 'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking ' +
34+ 'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! ' +
35+ 'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! ' +
36+ 'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty ' +
37+ 'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list ' +
38+ 'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer ' +
39+ 'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate ' +
40+ 'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta ' +
4041 'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'
41- } ;
42+ } ;
4243
4344 var SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>&#\'' ;
4445 var SYMBOL_RE = '[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:]*' ;
@@ -91,7 +92,22 @@ export default function(hljs) {
9192 } ;
9293 var DEFAULT_CONTAINS = [ LIST , STRING , HINT , HINT_COL , COMMENT , KEY , COLLECTION , NUMBER , LITERAL , SYMBOL ] ;
9394
94- LIST . contains = [ hljs . COMMENT ( 'comment' , '' ) , NAME , BODY ] ;
95+ var GLOBAL = {
96+ beginKeywords : globals ,
97+ end : '(\\[|\\#|\\d|"|:|\\{|\\)|\\(|$)' ,
98+ contains : [
99+ {
100+ className : 'title' ,
101+ begin : SYMBOL_RE ,
102+ relevance : 0 ,
103+ excludeEnd : true ,
104+ // we can only have a single title
105+ endsParent : true
106+ } ,
107+ ] . concat ( DEFAULT_CONTAINS )
108+ } ;
109+
110+ LIST . contains = [ hljs . COMMENT ( 'comment' , '' ) , GLOBAL , NAME , BODY ] ;
95111 BODY . contains = DEFAULT_CONTAINS ;
96112 COLLECTION . contains = DEFAULT_CONTAINS ;
97113 HINT_COL . contains = [ COLLECTION ] ;
@@ -101,5 +117,5 @@ export default function(hljs) {
101117 aliases : [ 'clj' ] ,
102118 illegal : / \S / ,
103119 contains : [ LIST , STRING , HINT , HINT_COL , COMMENT , KEY , COLLECTION , NUMBER , LITERAL ]
104- }
120+ } ;
105121}
0 commit comments