Skip to main content Svelte Highlight v7.21.1

Tree-sitter query language preview

1. Function definition query

node names, field names, and captures
horizon-dark
; match a function definition with a captured name
(function_item
  name: (identifier) @function.name
  parameters: (parameters) @function.params) @function.def

(call_expression
  function: [(identifier) (field_expression)] @call
  !type_arguments)

((identifier) @constant
  (#match? @constant "^[A-Z_]+$"))

(ERROR) @error
_ @any
atom-one-dark
; match a function definition with a captured name
(function_item
  name: (identifier) @function.name
  parameters: (parameters) @function.params) @function.def

(call_expression
  function: [(identifier) (field_expression)] @call
  !type_arguments)

((identifier) @constant
  (#match? @constant "^[A-Z_]+$"))

(ERROR) @error
_ @any
github-dark
; match a function definition with a captured name
(function_item
  name: (identifier) @function.name
  parameters: (parameters) @function.params) @function.def

(call_expression
  function: [(identifier) (field_expression)] @call
  !type_arguments)

((identifier) @constant
  (#match? @constant "^[A-Z_]+$"))

(ERROR) @error
_ @any
dracula
; match a function definition with a captured name
(function_item
  name: (identifier) @function.name
  parameters: (parameters) @function.params) @function.def

(call_expression
  function: [(identifier) (field_expression)] @call
  !type_arguments)

((identifier) @constant
  (#match? @constant "^[A-Z_]+$"))

(ERROR) @error
_ @any
nord
; match a function definition with a captured name
(function_item
  name: (identifier) @function.name
  parameters: (parameters) @function.params) @function.def

(call_expression
  function: [(identifier) (field_expression)] @call
  !type_arguments)

((identifier) @constant
  (#match? @constant "^[A-Z_]+$"))

(ERROR) @error
_ @any
github
; match a function definition with a captured name
(function_item
  name: (identifier) @function.name
  parameters: (parameters) @function.params) @function.def

(call_expression
  function: [(identifier) (field_expression)] @call
  !type_arguments)

((identifier) @constant
  (#match? @constant "^[A-Z_]+$"))

(ERROR) @error
_ @any

2. Predicates

eq?, match?, and any-of? directives
horizon-dark
((identifier) @variable.builtin
  (#any-of? @variable.builtin "self" "this" "super"))

((string) @string.special
  (#not-match? @string.special "^\\s*$"))
atom-one-dark
((identifier) @variable.builtin
  (#any-of? @variable.builtin "self" "this" "super"))

((string) @string.special
  (#not-match? @string.special "^\\s*$"))
github-dark
((identifier) @variable.builtin
  (#any-of? @variable.builtin "self" "this" "super"))

((string) @string.special
  (#not-match? @string.special "^\\s*$"))
dracula
((identifier) @variable.builtin
  (#any-of? @variable.builtin "self" "this" "super"))

((string) @string.special
  (#not-match? @string.special "^\\s*$"))
nord
((identifier) @variable.builtin
  (#any-of? @variable.builtin "self" "this" "super"))

((string) @string.special
  (#not-match? @string.special "^\\s*$"))
github
((identifier) @variable.builtin
  (#any-of? @variable.builtin "self" "this" "super"))

((string) @string.special
  (#not-match? @string.special "^\\s*$"))

3. Anonymous nodes and anchors

quoted terminals and the anchor operator
horizon-dark
(binary_expression
  left: (_) @left
  operator: "+"
  . right: (_) @right)
atom-one-dark
(binary_expression
  left: (_) @left
  operator: "+"
  . right: (_) @right)
github-dark
(binary_expression
  left: (_) @left
  operator: "+"
  . right: (_) @right)
dracula
(binary_expression
  left: (_) @left
  operator: "+"
  . right: (_) @right)
nord
(binary_expression
  left: (_) @left
  operator: "+"
  . right: (_) @right)
github
(binary_expression
  left: (_) @left
  operator: "+"
  . right: (_) @right)