Update Ruby Highlights (#6587)

* update ruby highlights

* Updated SQL injection.scm

* Move private, public, protected to builtin methods
pull/4381/head
Danillo Melo 2 years ago committed by GitHub
parent 4b32b544fc
commit 3dd715a115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -606,7 +606,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]] [[grammar]]
name = "ruby" name = "ruby"
source = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "4c600a463d97e36a0ca5ac57e11f3ac8c297a0fa" } source = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "206c7077164372c596ffa8eaadb9435c28941364" }
[[language]] [[language]]
name = "bash" name = "bash"

@ -1,44 +1,67 @@
; Keywords ; Keywords
[ [
"BEGIN"
"END"
"alias" "alias"
"and"
"begin" "begin"
"break"
"case"
"class" "class"
"def"
"do" "do"
"else"
"elsif"
"end" "end"
"ensure"
"for"
"if"
"in"
"module" "module"
"next" "in"
"or"
"rescue" "rescue"
"retry" "ensure"
"return" ] @keyword
"then"
"unless" [
"until" "if"
"else"
"elsif"
"when" "when"
"case"
"unless"
"then"
] @keyword.control.conditional
[
"for"
"while" "while"
"retry"
"until"
"redo"
] @keyword.control.repeat
[
"yield" "yield"
] @keyword "return"
"next"
"break"
] @keyword.control.return
[
"def"
"undef"
] @keyword.function
((identifier) @keyword.control.import
(#match? @keyword.control.import "^(require|require_relative|load|autoload)$"))
[
"or"
"and"
"not"
] @keyword.operator
((identifier) @keyword ((identifier) @keyword.control.exception
(#match? @keyword "^(private|protected|public)$")) (#match? @keyword.control.exception "^(raise|fail)$"))
; Function calls ; Function calls
((identifier) @function.method.builtin ((identifier) @function.builtin
(#eq? @function.method.builtin "require")) (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
"defined?" @function.method.builtin "defined?" @function.builtin
(call (call
method: [(identifier) (constant)] @function.method) method: [(identifier) (constant)] @function.method)
@ -58,7 +81,10 @@
] @variable.other.member ] @variable.other.member
((identifier) @constant.builtin ((identifier) @constant.builtin
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$")) (#match? @constant.builtin "^(__FILE__|__LINE__|__ENCODING__)$"))
((constant) @constant.builtin
(#match? @constant.builtin "^(ENV|ARGV|ARGF|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING)$"))
((constant) @constant ((constant) @constant
(#match? @constant "^[A-Z\\d_]+$")) (#match? @constant "^[A-Z\\d_]+$"))
@ -66,22 +92,23 @@
(constant) @constructor (constant) @constructor
(self) @variable.builtin (self) @variable.builtin
(super) @variable.builtin (super) @function.builtin
[(forward_parameter)(forward_argument)] @variable.parameter
(keyword_parameter name:((_)":" @variable.parameter) @variable.parameter)
(optional_parameter name:((_)"=" @operator) @variable.parameter)
(optional_parameter name: (identifier) @variable.parameter)
(splat_parameter name: (identifier) @variable.parameter) @variable.parameter
(hash_splat_parameter name: (identifier) @variable.parameter) @variable.parameter
(method_parameters (identifier) @variable.parameter)
(block_parameter (identifier) @variable.parameter) (block_parameter (identifier) @variable.parameter)
(block_parameters (identifier) @variable.parameter) (block_parameters (identifier) @variable.parameter)
(destructured_parameter (identifier) @variable.parameter)
(hash_splat_parameter (identifier) @variable.parameter)
(lambda_parameters (identifier) @variable.parameter)
(method_parameters (identifier) @variable.parameter)
(splat_parameter (identifier) @variable.parameter)
(keyword_parameter name: (identifier) @variable.parameter)
(optional_parameter name: (identifier) @variable.parameter)
((identifier) @function.method ((identifier) @function.method
(#is-not? local)) (#is-not? local))
(identifier) @variable [
(identifier)
] @variable
; Literals ; Literals
@ -96,10 +123,11 @@
[ [
(simple_symbol) (simple_symbol)
(delimited_symbol) (delimited_symbol)
(hash_key_symbol)
(bare_symbol) (bare_symbol)
] @string.special.symbol ] @string.special.symbol
(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
(regex) @string.regexp (regex) @string.regexp
(escape_sequence) @constant.character.escape (escape_sequence) @constant.character.escape
@ -112,7 +140,7 @@
(nil) (nil)
(true) (true)
(false) (false)
]@constant.builtin ] @constant.builtin
(interpolation (interpolation
"#{" @punctuation.special "#{" @punctuation.special
@ -121,20 +149,36 @@
(comment) @comment (comment) @comment
; Operators ; Operators
[ [
"=" ":"
"?"
"~"
"=>" "=>"
"->" "->"
"!"
] @operator ] @operator
(assignment
"=" @operator)
(operator_assignment
operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator)
(binary
operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator)
(range
operator: [".." "..."] @operator)
[ [
"," ","
";" ";"
"." "."
"&."
] @punctuation.delimiter ] @punctuation.delimiter
[ [
"|"
"(" "("
")" ")"
"[" "["

@ -1,2 +1,8 @@
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((heredoc_body
(heredoc_content) @injection.content
(heredoc_end) @name
(#set! injection.language "sql"))
(#eq? @name "SQL"))

Loading…
Cancel
Save