Skip to content

Commit df0d227

Browse files
committed
Support fun definitions
1 parent b7453ac commit df0d227

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

languages/ruby/highlights.scm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,38 @@
216216
(interpolation
217217
"#{" @punctuation.special
218218
"}" @punctuation.special) @embedded
219+
220+
221+
; fun function definitions
222+
((call
223+
method: (identifier) @methodName @keyword (#eq? @methodName "fun")
224+
arguments: (argument_list
225+
(pair
226+
key: [
227+
(call
228+
method: (identifier) @function.method)
229+
(identifier) @function.method
230+
(constant) @function.method
231+
]
232+
value: [
233+
[
234+
(call)
235+
(identifier)
236+
(constant)
237+
]
238+
]
239+
)
240+
)
241+
))
242+
243+
; fun keywords (void and never)
244+
((call
245+
method: (identifier) @keyword
246+
arguments: (argument_list
247+
(pair
248+
value: (identifier) @constant.builtin
249+
)
250+
)
251+
)
252+
(#eq? @keyword "fun")
253+
(#any-of? @constant.builtin "void" "never"))

languages/ruby/outline.scm

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,94 @@
239239
)
240240
)
241241
)
242+
243+
; fun method signature definitions
244+
(call
245+
method: (identifier) @methodName @context (#eq? @methodName "fun")
246+
arguments: (argument_list
247+
(pair
248+
key: [
249+
(call
250+
receiver: (_) @context
251+
operator: "." @context
252+
method: (identifier) @name
253+
)
254+
(call
255+
receiver: (_) @context
256+
operator: "." @context
257+
method: (identifier) @name
258+
arguments: (argument_list) @name
259+
)
260+
(call
261+
method: (identifier) @name
262+
)
263+
(call
264+
method: (identifier) @name
265+
arguments: (argument_list) @name
266+
)
267+
(identifier) @name
268+
]
269+
"=>" @name
270+
value: [
271+
(call
272+
method: (identifier) @name
273+
)
274+
(call
275+
method: (identifier) @name
276+
arguments: (argument_list) @name
277+
)
278+
(identifier) @name
279+
(constant) @name
280+
]
281+
)
282+
)
283+
block: (do_block)
284+
) @item
285+
286+
; fun method signature definitions with modifier
287+
(call
288+
method: (identifier) @context
289+
arguments: (argument_list
290+
(call
291+
method: (identifier) @methodName @context (#eq? @methodName "fun")
292+
arguments: (argument_list
293+
(pair
294+
key: [
295+
(call
296+
receiver: (_) @context
297+
operator: "." @context
298+
method: (identifier) @name
299+
)
300+
(call
301+
receiver: (_) @context
302+
operator: "." @context
303+
method: (identifier) @name
304+
arguments: (argument_list) @name
305+
)
306+
(call
307+
method: (identifier) @name
308+
)
309+
(call
310+
method: (identifier) @name
311+
arguments: (argument_list) @name
312+
)
313+
(identifier) @name
314+
]
315+
"=>" @name
316+
value: [
317+
(call
318+
method: (identifier) @name
319+
)
320+
(call
321+
method: (identifier) @name
322+
arguments: (argument_list) @name
323+
)
324+
(identifier) @name
325+
(constant) @name
326+
]
327+
)
328+
)
329+
)
330+
)
331+
block: (do_block)
332+
) @item

0 commit comments

Comments
 (0)