generated from nvim-treesitter/module-template
-
Notifications
You must be signed in to change notification settings - Fork 203
/
textobjects.scm
82 lines (75 loc) · 1.88 KB
/
textobjects.scm
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
; Block Objects
([
(do_block "do" . (_) @_do (_) @_end . "end")
(do_block "do" . ((_) @_do) @_end . "end")
] (#make-range! "block.inner" @_do @_end)) @block.outer
; Class Objects (Modules, Protocols)
(call
target: ((identifier) @_identifier (#any-of? @_identifier
"defmodule"
"defprotocol"
"defimpl"
))
(arguments (alias))
[
(do_block "do" . (_) @_do (_) @_end . "end")
(do_block "do" . ((_) @_do) @_end . "end")
]
(#make-range! "class.inner" @_do @_end)
) @class.outer
; Function, Parameter, and Call Objects
(anonymous_function
(stab_clause
right: (body) @function.inner)
) @function.outer
(call
target: ((identifier) @_identifier (#any-of? @_identifier
"def"
"defmacro"
"defmacrop"
"defn"
"defnp"
"defp"
))
(arguments (call [
(arguments (_) @parameter.inner . "," @_delimiter)
(arguments ((_) @parameter.inner) @_delimiter .)
] (#make-range! "parameter.outer" @parameter.inner @_delimiter)))
[
(do_block "do" . (_) @_do (_) @_end . "end")
(do_block "do" . ((_) @_do) @_end . "end")
]
(#make-range! "function.inner" @_do @_end)
) @function.outer
(call
target: ((identifier) @_identifier (#any-of? @_identifier
"def"
"defmacro"
"defmacrop"
"defn"
"defnp"
"defp"
))
(arguments (call [
(arguments (_) @parameter.inner . "," @_delimiter)
(arguments ((_) @parameter.inner) @_delimiter .)
] (#make-range! "parameter.outer" @parameter.inner @_delimiter))
(keywords
(pair
value: (_) @function.inner))
)
) @function.outer
; Comment Objects
(comment) @comment.outer
; Documentation Objects
(unary_operator
operator: "@"
operand: (call target: ((identifier) @_identifier (#any-of? @_identifier
"moduledoc"
"typedoc"
"shortdoc"
"doc"
)))
) @comment.outer
; Regex Objects
(sigil (quoted_content) @regex.inner) @regex.outer