@@ -207,8 +207,10 @@ Only intended for use at development time.")
207207 (or (group (or " ns" " fn" ))
208208 (group " def"
209209 (+ (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+ " *" " |" " ?" " <" " >" " +" " =" " :" ))))
212214 line-end))
213215
214216(defconst clojure-ts--variable-definition-symbol-regexp
@@ -247,6 +249,22 @@ Only intended for use at development time.")
247249 :anchor (str_lit) , capture-symbol
248250 :anchor (_)) ; the variable's value
249251 (: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" ))
250268 ; ; Captures docstrings defn, defmacro, ns, and things like that
251269 ((list_lit :anchor (sym_lit) @def_symbol
252270 :anchor (sym_lit) ; function_name
0 commit comments