@@ -207,8 +207,10 @@ Only intended for use at development time.")
207
207
(or (group (or " ns" " fn" ))
208
208
(group " def"
209
209
(+ (or alnum
210
- ; ; What are valid characters for symbols? is a negative match better?
211
- " -" " _" " !" " @" " #" " $" " %" " ^" " &" " *" " |" " ?" " <" " >" " +" " =" " :" ))))
210
+ ; ; What are valid characters for symbols?
211
+ ; ; is a negative match better?
212
+ " -" " _" " !" " @" " #" " $" " %" " ^" " &"
213
+ " *" " |" " ?" " <" " >" " +" " =" " :" ))))
212
214
line-end))
213
215
214
216
(defconst clojure-ts--variable-definition-symbol-regexp
@@ -247,6 +249,22 @@ Only intended for use at development time.")
247
249
:anchor (str_lit) , capture-symbol
248
250
:anchor (_)) ; the variable's value
249
251
(:match , clojure-ts--variable-definition-symbol-regexp @def_symbol))
252
+ ; ; Captures docstrings in metadata of definitions
253
+ ((list_lit :anchor (sym_lit) @def_symbol
254
+ :anchor (sym_lit
255
+ (meta_lit
256
+ value: (map_lit
257
+ (kwd_lit) @doc-keyword
258
+ :anchor
259
+ (str_lit) , capture-symbol ))))
260
+ ; ; We're only supporting this on a fixed set of defining symbols
261
+ ; ; Existing regexes don't encompass def and defn
262
+ ; ; Naming another regex is very cumbersome.
263
+ (:match ,(regexp-opt '(" def" " defonce" " defn" " defn-" " defmacro" " ns"
264
+ " defmulti" " definterface" " defprotocol"
265
+ " deftype" " defrecord" " defstruct" ))
266
+ @def_symbol)
267
+ (:equal @doc-keyword " :doc" ))
250
268
; ; Captures docstrings defn, defmacro, ns, and things like that
251
269
((list_lit :anchor (sym_lit) @def_symbol
252
270
:anchor (sym_lit) ; function_name
0 commit comments