Add context based highlighting for def, defn & ns

This commit is contained in:
Oliver Marshall 2021-06-06 13:19:18 +01:00 committed by Stephan Seitz
parent 16a06b30c2
commit 36964190f2

View file

@ -260,9 +260,63 @@
"vreset!" "with-bindings*" "with-meta" "with-redefs-fn" "xml-seq"
"zero?" "zipmap"))
;; >> Context based highlighting
; def-likes
; Correctly highlight docstrings
(list_lit
.
(sym_lit) @a
(#match? @a "^def.*")
.
(sym_lit)
.
(str_lit)? @text
.
(_))
; Funciton definitions
(list_lit
.
(sym_lit) @a
(#any-of? @a "fn" "fn*" "defn" "defn-")
.
(sym_lit)? @function
.
(str_lit)? @text)
;; TODO: Fix parameter highlighting
;; I think there's a bug here in nvim-treesitter
;; TODO: Reproduce bug and file ticket
;.
;[(vec_lit
; (sym_lit)* @parameter)
; (list_lit
; (vec_lit
; (sym_lit)* @parameter))])
;[((list_lit
; (vec_lit
; (sym_lit) @parameter)
; (_)
; +
; ((vec_lit
; (sym_lit) @parameter)
; (_)))
; Meta punctuation
;; NOTE: When the above `Function definitions` query captures the
;; the @function it also captures the child meta_lit
;; We capture the meta_lit symbol (^) after so that the later
;; highlighting overrides the former
"^" @punctuation.special
;; namespaces
(list_lit
.
(sym_lit) @a
(#eq? @a "ns")
.
(sym_lit) @namespace)