Skip to content

Commit e6b71bb

Browse files
committed
Support fun definitions
1 parent 76fed11 commit e6b71bb

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

languages/ruby/highlights.scm

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

languages/ruby/outline.scm

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,94 @@
344344
)
345345
)
346346
)
347+
348+
; fun method signature definitions
349+
(call
350+
method: (identifier) @methodName @context (#eq? @methodName "fun")
351+
arguments: (argument_list
352+
(pair
353+
key: [
354+
(call
355+
receiver: (_) @context
356+
operator: "." @context
357+
method: (identifier) @name
358+
)
359+
(call
360+
receiver: (_) @context
361+
operator: "." @context
362+
method: (identifier) @name
363+
arguments: (argument_list) @name
364+
)
365+
(call
366+
method: (identifier) @name
367+
)
368+
(call
369+
method: (identifier) @name
370+
arguments: (argument_list) @name
371+
)
372+
(identifier) @name
373+
]
374+
"=>" @name
375+
value: [
376+
(call
377+
method: (identifier) @name
378+
)
379+
(call
380+
method: (identifier) @name
381+
arguments: (argument_list) @name
382+
)
383+
(identifier) @name
384+
(constant) @name
385+
]
386+
)
387+
)
388+
block: (do_block)
389+
) @item
390+
391+
; fun method signature definitions with modifier
392+
(call
393+
method: (identifier) @context
394+
arguments: (argument_list
395+
(call
396+
method: (identifier) @methodName @context (#eq? @methodName "fun")
397+
arguments: (argument_list
398+
(pair
399+
key: [
400+
(call
401+
receiver: (_) @context
402+
operator: "." @context
403+
method: (identifier) @name
404+
)
405+
(call
406+
receiver: (_) @context
407+
operator: "." @context
408+
method: (identifier) @name
409+
arguments: (argument_list) @name
410+
)
411+
(call
412+
method: (identifier) @name
413+
)
414+
(call
415+
method: (identifier) @name
416+
arguments: (argument_list) @name
417+
)
418+
(identifier) @name
419+
]
420+
"=>" @name
421+
value: [
422+
(call
423+
method: (identifier) @name
424+
)
425+
(call
426+
method: (identifier) @name
427+
arguments: (argument_list) @name
428+
)
429+
(identifier) @name
430+
(constant) @name
431+
]
432+
)
433+
)
434+
)
435+
)
436+
block: (do_block)
437+
) @item

languages/ruby/textobjects.scm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@
1818
(method
1919
body: (_)? @function.inside) @function.around
2020

21+
(call
22+
method: (identifier) @methodName (#eq? @methodName "fun")
23+
block: (do_block
24+
body: (_)? @function.inside
25+
)) @function.around
26+
2127
; Comments
2228
(comment) @comment.inside

0 commit comments

Comments
 (0)