Remove some sections and add some missing things

The original approach was to emulate what was in Clojure's
highlights.scm file, but it appears that there were a number of
questionable items, so some sections were removed.

As a consequence, there were some items that ended up unmentioned.  An
attempt was made to rescue most of these and add some missing items to
a renamed "Special forms and builtin macros" section.

Five items were removed entirely.  These are:

* Single quote
* Tilde
* Pipe
* Comma
* Semicolon

It was unclear where to put these and it's also unclear whether
highlighting them would really be beneficial.  Perhaps what to do, if
anything, will become clear in the future.
This commit is contained in:
sogaiu
2023-04-25 22:34:56 +09:00
committed by Amaan Qureshi
parent b9d183c2c5
commit 6fe60587d1

View File

@@ -1,16 +1,3 @@
;; >> Explanation
;; Parsers for lisps are a bit weird in that they just return the raw forms.
;; This means we have to do a bit of extra work in the queries to get things
;; highlighted as they should be.
;;
;; For the most part this means that some things have to be assigned multiple
;; groups.
;; By doing this we can add a basic capture and then later refine it with more
;; specialized captures.
;; This can mean that sometimes things are highlighted weirdly because they
;; have multiple highlight groups applied to them.
;; >> Literals
(kwd_lit) @symbol
@@ -23,10 +10,6 @@
(nil_lit) @constant.builtin
(comment) @comment @spell
["'" "~"] @string.escape
["|" "," ";"] @punctuation.special
["{" "@{" "}"
"[" "@[" "]"
"(" "@(" ")"] @punctuation.bracket
@@ -46,6 +29,7 @@
(sym_lit) @function.call)
;; Quoted symbols
(quote_lit
(sym_lit) @symbol)
@@ -53,64 +37,38 @@
(sym_lit) @symbol)
;; Dynamic variables
((sym_lit) @variable.builtin
(#lua-match? @variable.builtin "^[*].+[*]$"))
;; Operators
((sym_lit) @operator
(#any-of? @operator
"%" "*" "+" "-" "/"
"<" "<=" "=" "==" ">" ">="))
((sym_lit) @keyword.operator
(#any-of? @keyword.operator
"not" "not=" "and" "or"))
;; Definition
((sym_lit) @keyword
(#any-of? @keyword
"def" "def-" "defdyn" "defglobal" "defmacro" "defmacro-"
"var" "var-" "varglobal"))
((sym_lit) @keyword.function
(#match? @keyword.function "^(defn|defn-|fn|varfn)$"))
;; Comment
((sym_lit) @comment
(#any-of? @comment "comment"))
;; Conditionals
((sym_lit) @conditional
(#any-of? @conditional
"case" "cond"))
((sym_lit) @conditional
(#match? @conditional "^if(\\-.*)?$"))
((sym_lit) @conditional
(#match? @conditional "^when(\\-.*)?$"))
;; Repeats
((sym_lit) @repeat
(#any-of? @repeat
"for" "forever" "forv" "loop" "repeat" "while"))
;; Exception
((sym_lit) @exception
(#any-of? @exception "error" "errorf" "try"))
;; Includes
((sym_lit) @include
(#any-of? @include "import" "require" "use"))
;; Builtin macros
;; Special forms and builtin macros
;;
;; # special forms were manually added at the beginning
;;
;; # for macros
;; (each name (all-bindings)
;; (when-let [info (dyn (symbol name))]
;; (when (info :macro)
;; (print name))))
((sym_lit) @function.macro
(#any-of? @function.macro
;; special forms
"break"
"def" "do"
"fn"
"if"
"quasiquote" "quote"
"set" "splice"
"unquote" "upscope"
"var"
"while"
;; macros
"%=" "*="
"++" "+="
"--" "-="
@@ -152,6 +110,7 @@
;; (or (function? (info :value))
;; (cfunction? (info :value))))
;; (print name))))
((sym_lit) @function.builtin
(#any-of? @function.builtin
"%" "*" "+" "-" "/"