From 2c67ca51a5f5f2a3b6c20d688692e5c702b1488a Mon Sep 17 00:00:00 2001 From: Oliver Marshall Date: Fri, 4 Jun 2021 23:56:35 +0100 Subject: All the other stuff, includes: - Changing huge 'match's to 'any-of's - Roughly organising the queries into sections - Add some TODOs for more improvements - Comment out def-like and call queries as they overlap too much - Change the captures to use better (imo) groups - Make with-.* and when-.* always highlight like a builtin --- queries/clojure/highlights.scm | 209 ++++++++++++++++++++++++++++++++++------- 1 file changed, 177 insertions(+), 32 deletions(-) (limited to 'queries/clojure') diff --git a/queries/clojure/highlights.scm b/queries/clojure/highlights.scm index 0e53284fe..b5ea4b265 100644 --- a/queries/clojure/highlights.scm +++ b/queries/clojure/highlights.scm @@ -40,9 +40,15 @@ (meta_lit marker: "^" @punctuation.special) -;;; parameter-related +;; TODO: Highlight code in comments? + +;; parameter-related ((sym_lit) @parameter -(#match? @parameter "^[&]")) + (#match? @parameter "^[&]")) + +;; TODO: General symbol highlighting +;((sym_lit) @symbol +; (#eq? @symbol @variable)) ;; dynamic variables ((sym_lit) @variable.builtin @@ -52,45 +58,184 @@ ((sym_lit) @variable (#match? @variable "^.*#$")) -;; def-like things -(list_lit - . - (sym_lit) @function.macro - . - (sym_lit) @function - (#any-of? @function.macro - "declare" "def" "definline" "definterface" - "defmacro" "defmethod" "defmulti" "defn" - "defn-" "defonce" "defprotocol" "defstruct" - "deftype" "ns")) -;; other macros -(list_lit - . - (sym_lit) @function.macro - (#match? @function.macro "^(\\.|\\.\\.|\\->|\\->>|amap|and|areduce|as\\->|assert|binding|bound\\-fn|case|catch|comment|cond|cond\\->|cond\\->>|condp|delay|do|doseq|dosync|dotimes|doto|extend-protocol|extend-type|finally|fn|fn\\*|for|future|gen-class|gen-interface|if|if\\-let|if\\-not|if\\-some|import|io!|lazy\\-cat|lazy\\-seq|let|letfn|locking|loop|memfn|monitor\\-enter|monitor\\-exit|or|proxy|proxy-super|pvalues|quote|recur|refer\\-clojure|reify|set!|some\\->|some\\->>|sync|throw|time|try|unquote|unquote\\-splicing|var|vswap!|when|when\\-first|when\\-let|when\\-not|when\\-some|while|with\\-bindings|with\\-in\\-str|with\\-loading\\-context|with\\-local\\-vars|with\\-open|with\\-out\\-str|with\\-precision|with\\-redefs)$")) -;; clojure.core=> (cp/pprint (sort (keep (fn [[s v]] (when-not (:macro (meta v)) s)) (ns-publics *ns*)))) -;; ...and then some manual filtering... -(list_lit - . - (sym_lit) @function.builtin - (#match? @function.builtin "^(\\*|\\*'|\\+|\\+'|\\-|\\-'|\\->ArrayChunk|\\->Eduction|\\->Vec|\\->VecNode|\\->VecSeq|\\-cache\\-protocol\\-fn|\\-reset\\-methods|/|<|<\\=|>|>\\=|\\=|\\=\\=|PrintWriter\\-on|StackTraceElement\\->vec|Throwable\\->map|accessor|aclone|add\\-classpath|add\\-tap|add\\-watch|agent|agent\\-error|agent\\-errors|aget|alength|alias|all\\-ns|alter|alter\\-meta!|alter\\-var\\-root|ancestors|any\\?|apply|array\\-map|aset|aset\\-boolean|aset\\-byte|aset\\-char|aset\\-double|aset\\-float|aset\\-int|aset\\-long|aset\\-short|assoc|assoc!|assoc\\-in|associative\\?|atom|await|await\\-for|await1|bases|bean|bigdec|bigint|biginteger|bit\\-and|bit\\-and\\-not|bit\\-clear|bit\\-flip|bit\\-not|bit\\-or|bit\\-set|bit\\-shift\\-left|bit\\-shift\\-right|bit\\-test|bit\\-xor|boolean|boolean\\-array|boolean\\?|booleans|bound\\-fn\\*|bound\\?|bounded\\-count|butlast|byte|byte\\-array|bytes|bytes\\?|cast|cat|char|char\\-array|char\\-escape\\-string|char\\-name\\-string|char\\?|chars|chunk|chunk\\-append|chunk\\-buffer|chunk\\-cons|chunk\\-first|chunk\\-next|chunk\\-rest|chunked\\-seq\\?|class|class\\?|clear\\-agent\\-errors|clojure\\-version|coll\\?|commute|comp|comparator|compare|compare\\-and\\-set!|compile|complement|completing|concat|conj|conj!|cons|constantly|construct\\-proxy|contains\\?|count|counted\\?|create\\-ns|create\\-struct|cycle|dec|dec'|decimal\\?|dedupe|default\\-data\\-readers|delay\\?|deliver|denominator|deref|derive|descendants|destructure|disj|disj!|dissoc|dissoc!|di