nvim-treesitter/queries/ruby/highlights.scm

294 lines
3.7 KiB
Scheme
Raw Normal View History

; Variables
[
(identifier)
(global_variable)
] @variable
; Keywords
[
2024-01-06 15:05:50 +09:00
"alias"
"begin"
"do"
"end"
"ensure"
"module"
"rescue"
"then"
] @keyword
2024-04-23 12:23:15 -07:00
"class" @keyword.type
[
2024-01-06 15:05:50 +09:00
"return"
"yield"
] @keyword.return
[
2024-01-06 15:05:50 +09:00
"and"
"or"
"in"
"not"
] @keyword.operator
[
"def"
"undef"
] @keyword.function
(method
"end" @keyword.function)
[
2024-01-06 15:05:50 +09:00
"case"
"else"
"elsif"
"if"
"unless"
"when"
"then"
] @keyword.conditional
(if
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
"end" @keyword.conditional)
[
2024-01-06 15:05:50 +09:00
"for"
"until"
"while"
"break"
"redo"
"retry"
"next"
] @keyword.repeat
(constant) @constant
((identifier) @keyword.modifier
(#any-of? @keyword.modifier "private" "protected" "public"))
2020-12-04 19:02:42 +00:00
[
2024-01-06 15:05:50 +09:00
"rescue"
"ensure"
] @keyword.exception
2020-12-04 19:02:42 +00:00
; Function calls
"defined?" @function
(call
2024-01-06 15:05:50 +09:00
receiver: (constant)? @type
method: [
(identifier)
(constant)
] @function.call)
(program
2024-01-06 15:05:50 +09:00
(call
(identifier) @keyword.import)
(#any-of? @keyword.import "require" "require_relative" "load"))
; Function definitions
2024-01-06 15:05:50 +09:00
(alias
(identifier) @function)
(setter
(identifier) @function)
2024-01-06 15:05:50 +09:00
(method
name: [
(identifier) @function
(constant) @type
])
2024-01-06 15:05:50 +09:00
(singleton_method
name: [
(identifier) @function
(constant) @type
])
2024-01-06 15:05:50 +09:00
(class
name: (constant) @type)
2024-01-06 15:05:50 +09:00
(module
name: (constant) @type)
2024-01-06 15:05:50 +09:00
(superclass
(constant) @type)
; Identifiers
[
2024-01-06 15:05:50 +09:00
(class_variable)
(instance_variable)
] @variable.member
((identifier) @constant.builtin
(#any-of? @constant.builtin
"__callee__" "__dir__" "__id__" "__method__" "__send__" "__ENCODING__" "__FILE__" "__LINE__"))
((identifier) @function.builtin
(#any-of? @function.builtin
"include" "extend" "prepend" "attr_reader" "attr_writer" "attr_accessor" "module_function"
"refine" "using"))
((identifier) @keyword.exception
(#any-of? @keyword.exception "raise" "fail" "catch" "throw"))
((constant) @type
2024-01-06 15:05:50 +09:00
(#not-lua-match? @type "^[A-Z0-9_]+$"))
[
2024-01-06 15:05:50 +09:00
(self)
(super)
] @variable.builtin
(method_parameters
(identifier) @variable.parameter)
(lambda_parameters
(identifier) @variable.parameter)
(block_parameters
(identifier) @variable.parameter)
(splat_parameter
(identifier) @variable.parameter)
(hash_splat_parameter
(identifier) @variable.parameter)
(optional_parameter
(identifier) @variable.parameter)
(destructured_parameter
(identifier) @variable.parameter)
(block_parameter
(identifier) @variable.parameter)
(keyword_parameter
(identifier) @variable.parameter)
; TODO: Re-enable this once it is supported
; ((identifier) @function
; (#is-not? local))
; Literals
[
2024-01-06 15:05:50 +09:00
(string)
(bare_string)
(subshell)
(heredoc_body)
] @string
[
2024-01-06 15:05:50 +09:00
(heredoc_beginning)
(heredoc_end)
] @label
[
2024-01-06 15:05:50 +09:00
(bare_symbol)
(simple_symbol)
(delimited_symbol)
(hash_key_symbol)
] @string.special.symbol
(pair
key: (hash_key_symbol)
":" @constant)
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(regex) @string.regexp
2024-01-06 15:05:50 +09:00
(escape_sequence) @string.escape
2024-01-06 15:05:50 +09:00
(integer) @number
2024-01-06 15:05:50 +09:00
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(float) @number.float
[
2024-01-06 15:05:50 +09:00
(true)
(false)
] @boolean
(nil) @constant.builtin
(comment) @comment @spell
(program
(comment)+ @comment.documentation
(class))
(module
(comment)+ @comment.documentation
2024-01-06 15:05:50 +09:00
(body_statement
(class)))
(class
(comment)+ @comment.documentation
2024-01-06 15:05:50 +09:00
(body_statement
(method)))
(body_statement
(comment)+ @comment.documentation
(method))
; Operators
[
2024-01-06 15:05:50 +09:00
"!"
"="
"=="
"==="
"<=>"
"=>"
"->"
">>"
"<<"
">"
"<"
">="
"<="
"**"
"*"
"/"
"%"
"+"
"-"
"&"
"|"
"^"
"&&"
"||"
"||="
"&&="
"!="
"%="
"+="
"-="
"*="
"/="
"=~"
"!~"
"?"
":"
".."
"..."
] @operator
[
2024-01-06 15:05:50 +09:00
","
";"
"."
] @punctuation.delimiter
[
2024-01-06 15:05:50 +09:00
"("
")"
"["
"]"
"{"
"}"
"%w("
"%i("
] @punctuation.bracket
(interpolation
"#{" @punctuation.special
"}" @punctuation.special) @none