[
  "{{"
  "{{-"
  "{{+"
  "+}}"
  "-}}"
  "}}"
  "{%"
  "{%-"
  "{%+"
  "+%}"
  "-%}"
  "%}"
] @keyword

(string_literal) @string

(number_literal) @value.number
(float_literal) @value.number.float
(boolean_literal) @value.boolean
(null_literal) @value.null

"defined" @identifier.constant

(comment) @comment

[
  ","
  "."
  ":"
] @punctuation.delimiter

[
  (attribute_ignore)
  (attribute_context)
  "recursive"
] @attribute.builtin

[
  "("
  ")"
  "["
  "]"
  "<"
  ">"
] @punctuation.bracket

(binary_operator) @operator

[
  "block"
  "with"
  "filter"
  "macro"
  "set"
  "trans"
  "pluralize"
  "autoescape"
] @keyword

[
  "endtrans"
  "endblock"
  "endwith"
  "endfilter"
  "endmacro"
  "endcall"
  "endset"
  "endtrans"
  "endautoescape"
] @keyword

(do_statement
  "do" @keyword)

[
  "extends"
  "include"
  "import"
  "from"
  "continue"
  "break"
] @keyword

[
  "as"
  "in"
] @keyword.modifier

(import_statement
  (identifier) @identifier.variable)

(import_as
  (identifier) @identifier.variable)

[
  "if"
  "elif"
  "else"
  "endif"
  "for"
  "endfor"
] @keyword.condition

"call" @identifier.function.call

(function_call
  (identifier) @identifier.function.call)

(arg
  (identifier) @identifier.argument)

(arg
  (expression
    (binary_expression
      (unary_expression
        (primary_expression
          (identifier) @identifier.argument)))))

(expression
  "."
  (expression)+ @identifier.property)

(assignment_expression
  "."
  (identifier)+ @identifier.property)

(inline_trans
  "_" @identifier.function.builtin)

"debug" @identifier.function.builtin

; TODO: only match raw
(raw_start) @keyword
(raw_end) @keyword
(raw_body) @markup.raw.block

(builtin_test
  [
    "boolean"
    "even"
    "in"
    "mapping"
    "sequence"
    "callable"
    "integer"
    "ne"
    "string"
    "defined"
    "filter"
    "iterable"
    "none"
    "test"
    "divisibleby"
    "float"
    "le"
    "number"
    "eq"
    "ge"
    "lower"
    "odd"
    "undefined"
    "escaped"
    "gt"
    "lt"
    "sameas"
    "upper"
  ] @keyword.operator)
