diff --git a/languages/ruby/highlights.scm b/languages/ruby/highlights.scm index 2ee9103..b41343e 100644 --- a/languages/ruby/highlights.scm +++ b/languages/ruby/highlights.scm @@ -214,3 +214,38 @@ (interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded + + +; fun function definitions +((call + method: (identifier) @methodName @keyword (#eq? @methodName "fun") + arguments: (argument_list + (pair + key: [ + (call + method: (identifier) @function.method) + (identifier) @function.method + (constant) @function.method + ] + value: [ + [ + (call) + (identifier) + (constant) + ] + ] + ) + ) +)) + +; fun keywords (void and never) +((call + method: (identifier) @keyword + arguments: (argument_list + (pair + value: (identifier) @constant.builtin + ) + ) +) + (#eq? @keyword "fun") + (#any-of? @constant.builtin "void" "never")) diff --git a/languages/ruby/outline.scm b/languages/ruby/outline.scm index 105491b..2063c2d 100644 --- a/languages/ruby/outline.scm +++ b/languages/ruby/outline.scm @@ -344,3 +344,94 @@ ) ) ) + +; fun method signature definitions +(call + method: (identifier) @methodName @context (#eq? @methodName "fun") + arguments: (argument_list + (pair + key: [ + (call + receiver: (_) @context + operator: "." @context + method: (identifier) @name + ) + (call + receiver: (_) @context + operator: "." @context + method: (identifier) @name + arguments: (argument_list) @name + ) + (call + method: (identifier) @name + ) + (call + method: (identifier) @name + arguments: (argument_list) @name + ) + (identifier) @name + ] + "=>" @name + value: [ + (call + method: (identifier) @name + ) + (call + method: (identifier) @name + arguments: (argument_list) @name + ) + (identifier) @name + (constant) @name + ] + ) + ) + block: (do_block) +) @item + +; fun method signature definitions with modifier +(call + method: (identifier) @context + arguments: (argument_list + (call + method: (identifier) @methodName @context (#eq? @methodName "fun") + arguments: (argument_list + (pair + key: [ + (call + receiver: (_) @context + operator: "." @context + method: (identifier) @name + ) + (call + receiver: (_) @context + operator: "." @context + method: (identifier) @name + arguments: (argument_list) @name + ) + (call + method: (identifier) @name + ) + (call + method: (identifier) @name + arguments: (argument_list) @name + ) + (identifier) @name + ] + "=>" @name + value: [ + (call + method: (identifier) @name + ) + (call + method: (identifier) @name + arguments: (argument_list) @name + ) + (identifier) @name + (constant) @name + ] + ) + ) + ) + ) + block: (do_block) +) @item diff --git a/languages/ruby/textobjects.scm b/languages/ruby/textobjects.scm index fa19476..7363f5e 100644 --- a/languages/ruby/textobjects.scm +++ b/languages/ruby/textobjects.scm @@ -18,5 +18,11 @@ (method body: (_)? @function.inside) @function.around +(call + method: (identifier) @methodName (#eq? @methodName "fun") + block: (do_block + body: (_)? @function.inside + )) @function.around + ; Comments (comment) @comment.inside