mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 03:10:04 -04:00
refactor: use newly introduced consolidated syntax
This commit is contained in:
parent
772aa4c169
commit
0f836e0602
5 changed files with 197 additions and 135 deletions
|
|
@ -1,32 +1,41 @@
|
|||
; Keywords
|
||||
|
||||
"alias" @keyword
|
||||
"and" @keyword
|
||||
"begin" @keyword
|
||||
"break" @keyword
|
||||
"case" @conditional
|
||||
"class" @keyword
|
||||
"def" @keyword
|
||||
"do" @keyword
|
||||
"else" @conditional
|
||||
"elsif" @conditional
|
||||
"end" @keyword
|
||||
"ensure" @keyword
|
||||
"for" @repeat
|
||||
"if" @conditional
|
||||
"in" @keyword
|
||||
"module" @keyword
|
||||
"next" @keyword
|
||||
"or" @keyword
|
||||
"rescue" @keyword
|
||||
"retry" @keyword
|
||||
"return" @keyword
|
||||
"then" @keyword
|
||||
"unless" @conditional
|
||||
"until" @repeat
|
||||
"when" @conditional
|
||||
"while" @repeat
|
||||
"yield" @keyword
|
||||
[
|
||||
"alias"
|
||||
"and"
|
||||
"begin"
|
||||
"break"
|
||||
"class"
|
||||
"def"
|
||||
"do"
|
||||
"end"
|
||||
"ensure"
|
||||
"in"
|
||||
"module"
|
||||
"next"
|
||||
"or"
|
||||
"rescue"
|
||||
"retry"
|
||||
"return"
|
||||
"then"
|
||||
"yield"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"case"
|
||||
"else"
|
||||
"elsif"
|
||||
"if"
|
||||
"unless"
|
||||
"when"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"for"
|
||||
"until"
|
||||
"while"
|
||||
] @repeat
|
||||
|
||||
|
||||
((identifier) @keyword
|
||||
(#match? @keyword "^(private|protected|public)$"))
|
||||
|
|
@ -39,32 +48,45 @@
|
|||
"defined?" @function
|
||||
|
||||
(call
|
||||
receiver: (constant) @constant)
|
||||
[
|
||||
receiver: (constant) @constant
|
||||
method: [
|
||||
(identifier)
|
||||
(constant)
|
||||
] @function
|
||||
])
|
||||
|
||||
(method_call
|
||||
receiver: (constant) @constant)
|
||||
(call
|
||||
method: (identifier) @function)
|
||||
(method_call
|
||||
method: (identifier) @function)
|
||||
(call
|
||||
method: (constant) @function)
|
||||
(method_call
|
||||
method: (constant) @function)
|
||||
[
|
||||
receiver: (constant) @constant
|
||||
method: [
|
||||
(identifier)
|
||||
(constant)
|
||||
] @function
|
||||
])
|
||||
|
||||
; Function definitions
|
||||
|
||||
(alias (identifier) @function)
|
||||
(setter (identifier) @function)
|
||||
(method name: (identifier) @function)
|
||||
(method name: (constant) @constant)
|
||||
|
||||
(method name: [
|
||||
(identifier) @function
|
||||
(constant) @constant
|
||||
])
|
||||
|
||||
(singleton_method name: [
|
||||
(identifier) @function
|
||||
(constant) @constant
|
||||
])
|
||||
|
||||
(class name: (constant) @constant)
|
||||
(singleton_method name: (identifier) @function)
|
||||
(singleton_method name: (constant) @constant)
|
||||
|
||||
; Identifiers
|
||||
|
||||
(class_variable) @label
|
||||
(instance_variable) @label
|
||||
[
|
||||
(class_variable)
|
||||
(instance_variable)
|
||||
] @label
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
|
||||
|
|
@ -74,8 +96,10 @@
|
|||
|
||||
(constant) @constant
|
||||
|
||||
(self) @constant.builtin
|
||||
(super) @constant.builtin
|
||||
[
|
||||
(self)
|
||||
(super)
|
||||
] @constant.builtin
|
||||
|
||||
(method_parameters (identifier) @parameter)
|
||||
(lambda_parameters (identifier) @parameter)
|
||||
|
|
@ -93,22 +117,30 @@
|
|||
|
||||
; Literals
|
||||
|
||||
(string) @string
|
||||
(bare_string) @string
|
||||
(bare_symbol) @constant
|
||||
(subshell) @string
|
||||
(heredoc_beginning) @constant
|
||||
(heredoc_body) @string
|
||||
(heredoc_end) @constant
|
||||
(symbol) @constant
|
||||
[
|
||||
(string)
|
||||
(bare_string)
|
||||
(subshell)
|
||||
(heredoc_body)
|
||||
] @string
|
||||
|
||||
[
|
||||
(bare_symbol)
|
||||
(heredoc_beginning)
|
||||
(heredoc_end)
|
||||
(symbol)
|
||||
] @constant
|
||||
|
||||
(regex) @string.regex
|
||||
(escape_sequence) @string.escape
|
||||
(integer) @number
|
||||
(float) @float
|
||||
|
||||
(nil) @boolean
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
[
|
||||
(nil)
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(interpolation
|
||||
"#{" @punctuation.bracket
|
||||
|
|
@ -118,25 +150,31 @@
|
|||
|
||||
; Operators
|
||||
|
||||
"=" @operator
|
||||
"=>" @operator
|
||||
"->" @operator
|
||||
"+" @operator
|
||||
"-" @operator
|
||||
"*" @operator
|
||||
"/" @operator
|
||||
[
|
||||
"="
|
||||
"=>"
|
||||
"->"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
] @operator
|
||||
|
||||
"," @punctuation.delimiter
|
||||
";" @punctuation.delimiter
|
||||
"." @punctuation.delimiter
|
||||
[
|
||||
","
|
||||
";"
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
"%w(" @punctuation.bracket
|
||||
"%i(" @punctuation.bracket
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"%w("
|
||||
"%i("
|
||||
] @punctuation.bracket
|
||||
|
||||
(ERROR) @error
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@
|
|||
((method) @scope
|
||||
(set! scope-inherits false))
|
||||
|
||||
(block) @scope
|
||||
(do_block) @scope
|
||||
[
|
||||
(block)
|
||||
(do_block)
|
||||
] @scope
|
||||
|
||||
(method_parameters (identifier) @definition.function)
|
||||
(lambda_parameters (identifier) @definition.function)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue