nvim-treesitter/queries/php/highlights.scm

374 lines
4.5 KiB
Scheme
Raw Normal View History

; Variables
(variable_name) @variable
; Constants
((name) @constant
2024-01-06 15:05:50 +09:00
(#lua-match? @constant "^_?[A-Z][A-Z%d_]*$"))
((name) @constant.builtin
2024-01-06 15:05:50 +09:00
(#lua-match? @constant.builtin "^__[A-Z][A-Z%d_]+__$"))
2024-01-06 15:05:50 +09:00
(const_declaration
(const_element
(name) @constant))
; Types
[
2024-01-06 15:05:50 +09:00
(primitive_type)
(cast_type)
(bottom_type)
] @type.builtin
(named_type
2024-01-06 15:05:50 +09:00
[
(name) @type
(qualified_name
(name) @type)
])
(class_declaration
name: (name) @type)
2024-01-06 15:05:50 +09:00
(base_clause
2024-01-06 15:05:50 +09:00
[
(name) @type
(qualified_name
(name) @type)
])
(enum_declaration
name: (name) @type)
2024-01-06 15:05:50 +09:00
(interface_declaration
name: (name) @type)
2024-01-06 15:05:50 +09:00
(namespace_use_clause
2024-01-06 15:05:50 +09:00
[
(name) @type
(qualified_name
(name) @type)
])
(namespace_aliasing_clause
(name) @type.definition)
(class_interface_clause
2024-01-06 15:05:50 +09:00
[
(name) @type
(qualified_name
(name) @type)
])
(scoped_call_expression
2024-01-06 15:05:50 +09:00
scope:
[
(name) @type
(qualified_name
(name) @type)
])
(class_constant_access_expression
2024-01-06 15:05:50 +09:00
.
[
(name) @type
(qualified_name
(name) @type)
]
(name) @constant)
2024-01-06 15:05:50 +09:00
(trait_declaration
name: (name) @type)
2024-01-06 15:05:50 +09:00
(use_declaration
2024-01-06 15:05:50 +09:00
(name) @type)
2023-01-28 15:13:33 +07:00
(binary_expression
operator: "instanceof"
2024-01-06 15:05:50 +09:00
right:
[
(name) @type
(qualified_name
(name) @type)
])
; Functions, methods, constructors
2024-01-06 15:05:50 +09:00
(array_creation_expression
"array" @function.builtin)
2024-01-06 15:05:50 +09:00
(list_literal
"list" @function.builtin)
(method_declaration
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
name: (name) @function.method)
(function_call_expression
2024-01-06 15:05:50 +09:00
function:
(qualified_name
(name) @function.call))
(function_call_expression
(name) @function.call)
(scoped_call_expression
name: (name) @function.call)
(member_call_expression
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
name: (name) @function.method.call)
(function_definition
name: (name) @function)
(nullsafe_member_call_expression
2024-01-06 15:05:50 +09:00
name: (name) @function.method)
(method_declaration
2024-01-06 15:05:50 +09:00
name: (name) @constructor
(#eq? @constructor "__construct"))
(object_creation_expression
2024-01-06 15:05:50 +09:00
[
(name) @constructor
(qualified_name
(name) @constructor)
])
; Parameters
[
(simple_parameter)
(variadic_parameter)
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
] @variable.parameter
(argument
2024-01-06 15:05:50 +09:00
(name) @variable.parameter)
; Member
(property_element
(variable_name) @property)
(member_access_expression
2024-01-06 15:05:50 +09:00
name:
(variable_name
(name)) @property)
2020-08-05 14:48:42 +09:00
(member_access_expression
name: (name) @property)
; Variables
(relative_scope) @variable.builtin
((variable_name) @variable.builtin
2024-01-06 15:05:50 +09:00
(#eq? @variable.builtin "$this"))
; Namespace
(namespace_definition
2024-01-06 15:05:50 +09:00
name:
(namespace_name
(name) @module))
(namespace_name_as_prefix
2024-01-06 15:05:50 +09:00
(namespace_name
(name) @module))
; Attributes
(attribute_list) @attribute
; Conditions ( ? : )
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
(conditional_expression) @keyword.conditional
; Directives
2024-01-06 15:05:50 +09:00
(declare_directive
[
"strict_types"
"ticks"
"encoding"
] @variable.parameter)
; Basic tokens
[
2024-01-06 15:05:50 +09:00
(string)
(encapsed_string)
(heredoc_body)
(nowdoc_body)
(shell_command_expression) ; backtick operator: `ls -la`
] @string
(escape_sequence) @string.escape
[
2024-01-06 15:05:50 +09:00
(heredoc_start)
(heredoc_end)
] @label
2024-01-06 15:05:50 +09:00
(nowdoc
"'" @label)
(boolean) @boolean
2024-01-06 15:05:50 +09:00
(null) @constant.builtin
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
2022-09-20 13:12:19 +02:00
(comment) @comment @spell
(named_label_statement) @label
2024-01-06 15:05:50 +09:00
; Keywords
[
2024-01-06 15:05:50 +09:00
"and"
"as"
"instanceof"
"or"
"xor"
] @keyword.operator
[
2024-01-06 15:05:50 +09:00
"fn"
"function"
] @keyword.function
[
2024-01-06 15:05:50 +09:00
"break"
"class"
"clone"
"declare"
"default"
"echo"
"enddeclare"
"enum"
"extends"
"global"
"goto"
"implements"
"insteadof"
"interface"
"namespace"
"new"
"trait"
"unset"
] @keyword
[
2024-01-06 15:05:50 +09:00
"abstract"
"const"
"final"
"private"
"protected"
"public"
"readonly"
"static"
] @type.qualifier
[
"return"
"yield"
] @keyword.return
[
2024-01-06 15:05:50 +09:00
"case"
"else"
"elseif"
"endif"
"endswitch"
"if"
"switch"
"match"
"??"
2024-01-06 15:05:50 +09:00
] @keyword.conditional
[
2024-01-06 15:05:50 +09:00
"continue"
"do"
"endfor"
"endforeach"
"endwhile"
"for"
"foreach"
"while"
] @keyword.repeat
[
2024-01-06 15:05:50 +09:00
"catch"
"finally"
"throw"
"try"
] @keyword.exception
[
2024-01-06 15:05:50 +09:00
"include_once"
"include"
"require_once"
"require"
"use"
] @keyword.import
[
2024-01-06 15:05:50 +09:00
","
";"
":"
"\\"
] @punctuation.delimiter
[
2024-01-06 15:05:50 +09:00
(php_tag)
"?>"
"("
")"
"["
"]"
"{"
"}"
"#["
] @punctuation.bracket
[
"="
"."
"-"
"*"
"/"
"+"
"%"
"**"
"~"
"|"
"^"
"&"
"<<"
">>"
"<<<"
"->"
"?->"
"=>"
"<"
"<="
">="
">"
"<>"
"=="
"!="
"==="
"!=="
"!"
"&&"
"||"
".="
"-="
"+="
"*="
"/="
"%="
"**="
"&="
"|="
"^="
"<<="
">>="
"??="
"--"
"++"
"@"
"::"
] @operator