aboutsummaryrefslogtreecommitdiffstats
path: root/queries/commonlisp/highlights.scm
blob: 5cf7c1eb036043afe4008d7a2a80925fc4a19f00 (plain) (blame)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
(sym_lit) @variable

;; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp
;(list_lit . (sym_lit) @function.builtin (#cl-standard-function? @function.builtin))
;(list_lit . (sym_lit) @function.builtin (#cl-standard-macro? @function.macro))

(dis_expr) @comment

(defun_keyword) @function.macro
(defun_header
  function_name: (_) @function)
(defun_header
  lambda_list: (list_lit (sym_lit) @parameter))
(defun_header
  keyword: (defun_keyword "defmethod")
  lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @symbol)))
(defun_header
  lambda_list: (list_lit (list_lit . (sym_lit) @parameter . (_))))
(defun_header
  specifier: (sym_lit) @symbol)

[":" "::" "."] @punctuation.special

[
  (accumulation_verb)
  (for_clause_word)
  "for"
  "and"
  "finally"
  "thereis"
  "always"
  "when"
  "if"
  "unless"
  "else"
  "do"
  "loop"
  "below"
  "in"
  "from"
  "across"
  "repeat"
  "being"
  "into"
  "with"
  "as"
  "while"
  "until"
  "return"
  "initially"
] @function.macro
"=" @operator

(include_reader_macro) @symbol
["#C" "#c"] @number

[(kwd_lit) (self_referential_reader_macro)] @symbol

(package_lit
  package: (_) @namespace)
"cl" @namespace

(str_lit) @string

(num_lit) @number

((sym_lit)  @boolean (#match? @boolean "^(t|T)$"))

(nil_lit) @constant.builtin

(comment) @comment

;; dynamic variables
((sym_lit) @variable.builtin
 (#match? @variable.builtin "^[*].+[*]$"))

;; quote
"'" @string.escape
(format_specifier) @string.escape
(quoting_lit) @string.escape

;; syntax quote
"`" @string.escape
"," @string.escape
",@" @string.escape
(syn_quoting_lit) @string.escape
(unquoting_lit) @none
(unquote_splicing_lit) @none


["(" ")"] @punctuation.bracket

(block_comment) @comment


(with_clause
  type: (_) @type)
(for_clause
  type: (_) @type)

;; defun-like things
(list_lit
 .
 (sym_lit) @function.macro
 .
 (sym_lit) @function
 (#eq? @function.macro "deftest"))

;;; Macros and Special Operators
(list_lit
 .
 (sym_lit) @function.macro
 ;; For a complete and more efficient version install theHamsta/nvim-treesitter-commonlisp
 (#any-of? @function.macro
          "let"
          "function"
          "the"
          "unwind-protect"
          "labels"
          "flet"
          "tagbody"
          "go"
          "symbol-macrolet"
          "symbol-macrolet"
          "progn"
          "prog1"
          "error"
          "or"
          "and"
          "defvar"
          "defparameter"
          "in-package"
          "defpackage"
          "case"
          "ecase"
          "typecase"
          "etypecase"
          "defstruct"
          "defclass"
          "if"
          "when"
          "unless"
          "cond"
          "switch"
          "declaim"
          "optimize"))

;; constant
((sym_lit) @constant
 (#match? @constant "^[+].+[+]$"))

(var_quoting_lit
  marker: "#'" @symbol
  value: (_) @symbol)

["#" "#p" "#P"] @symbol

(list_lit
 .
 (sym_lit) @function.builtin
 ;; For a complete and more efficient version install theHamsta/nvim-treesitter-commonlisp
 (#any-of? @function.builtin
           "mapcar"
           "reduce"
           "remove-if-not"
           "cons"
           "car"
           "last"
           "nth"
           "equal"
           "cdr"
           "first"
           "rest"
           "format"))

(list_lit
 .
 (sym_lit) @operator
 (#match? @operator "^([+*-+=<>]|<=|>=|/=)$"))


((sym_lit) @symbol
(#match? @symbol "^[&]"))

[(array_dimension) "#0A" "#0a"] @number

(char_lit) @character