filetype: odin

detect:
    filename: "\\.odin$"

rules:
    # Conditionals and control flow
    - special: "\\b(asm|auto_cast|break|case|cast|context|continue|do|dynamic|fallthrough|return|transmute|using|where)\\b"
    - statement: "\\b(else|for|if|switch|in|not_in|or_else|or_return|when)\\b"
    - preproc: "\\b(assert|package|foreign|import|proc|defer|make|new|free|delete|copy|len|cap|append|raw_data)\\b"
    - preproc: "\\b((size|align|offset|type|type_info|typeid)_of|offset_of_by_string)\\b"
    - preproc: "\\b(swizzle|complex|quaternion|real|imag|jmag|kmag|conj|expand_to_tuple|min|max|abs|clamp|soa_zip|soa_unzip|transpose|outer_product|hadamard_product|matrix_flatten)\\b"
    - symbol.operator: "[-+/*=<>!~%&|^@]|:\\s*=|:\\s*:|\\?"

      # Types
    - symbol: "(,|\\.)"
    - type: "\\b(b(8|16|32|64)|(i|u)(8|(16|32|64|128)(le|be)?)|f(16|32|64)(le|be)?|complex(32|64|128)|quaternion(64|128|256))\\b"
    - type: "\\b(any|bool|byte|rune|u?int|uintptr|rawptr|c?string|map|matrix|typeid)\\b"
    - type.keyword: "\\b(distinct|struct|enum|union|bit_set)\\b"
    - constant.bool: "\\b(true|false|nil)\\b"

      # Brackets
    - symbol.brackets: "(\\{|\\})"
    - symbol.brackets: "(\\(|\\))"
    - symbol.brackets: "(\\[|\\])"

      # Numbers and strings
    - constant.number: "\\b(0b[01]*|0o[0-7]*|0x[0-9a-fA-F]*|[0-9_]+|0d[0-9]*|0z[0-9abAB]*)\\b|'.'"

    - constant.string:
        start: "\""
        end: "\""
        skip: "\\\\."
        rules:
            - constant.specialChar: "%."
            - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
            - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"

    - constant.string:
        start: "'"
        end: "'"
        skip: "\\\\."
        rules:
            - error: "..+"
            - constant.specialChar: "%."
            - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
            - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"

    - constant.string:
        start: "`"
        end: "`"
        rules: []

    - comment:
        start: "//"
        end: "$"
        rules:
            - todo: "TODO:?|NOTE(\\(.*\\))?:?"

    - comment:
        start: "/\\*"
        end: "\\*/"
        rules:
            - todo: "TODO:?|NOTE(\\(.*\\))?:?"
