summaryrefslogtreecommitdiff
path: root/vendor/queries/clojure/textobjects.scm
blob: 5121ff8c3ebf4f36fd278388dc984516f8d672db (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
; Vendored from helix (https://github.com/helix-editor/helix) at 278b24389:
; runtime/queries/clojure/textobjects.scm.
; Licensed under the Mozilla Public License 2.0 (vendor/queries/helix.LICENSE,
; https://mozilla.org/MPL/2.0/).

; Function definitions (defn, defn-, defmacro, defmethod, etc.)
(list_lit
  .
  (sym_lit) @_keyword
  .
  (sym_lit)
  (_)* @function.inside
  (#match? @_keyword "^(defn|defn-|defmacro|defmethod|defmulti|definline)$")) @function.around

; Anonymous functions (fn)
(list_lit
  .
  (sym_lit) @_fn
  (_)* @function.inside
  (#match? @_fn "^fn$")) @function.around

; Anonymous function shorthand #()
(anon_fn_lit
  (_)* @function.inside) @function.around

; deftype, defrecord, defprotocol
(list_lit
  .
  (sym_lit) @_keyword
  .
  (sym_lit)
  (_)* @class.inside
  (#match? @_keyword "^(deftype|defrecord|defprotocol|definterface|defstruct)$")) @class.around

; Test definitions (deftest)
(list_lit
  .
  (sym_lit) @_keyword
  .
  (sym_lit)
  (_)* @test.inside
  (#match? @_keyword "^deftest$")) @test.around

; Function parameters in vectors
(vec_lit
  (_)* @parameter.inside) @parameter.around

; List entries
(list_lit
  (_) @entry.inside @entry.around)

; Vector entries
(vec_lit
  (_) @entry.inside @entry.around)

; Map entries
(map_lit
  (_) @entry.inside @entry.around)

; Set entries
(set_lit
  (_) @entry.inside @entry.around)

; Comments
(comment) @comment.inside
(comment)+ @comment.around

; Discard expressions (also treated as comments)
(dis_expr) @comment.inside

; Comment special form (comment ...)
(list_lit
  .
  (sym_lit) @_comment
  (_)* @comment.inside
  (#match? @_comment "^comment$")) @comment.around