; Syntax highlighting queries for Lux

; Comments
(line_comment) @comment
(doc_comment) @comment.documentation

; Keywords
[
  "fn"
  "let"
  "type"
  "effect"
  "handler"
  "trait"
  "impl"
  "for"
  "import"
  "export"
  "match"
  "if"
  "then"
  "else"
  "with"
  "run"
  "resume"
  "is"
] @keyword

; Operators
[
  "+"
  "-"
  "*"
  "/"
  "%"
  "=="
  "!="
  "<"
  ">"
  "<="
  ">="
  "&&"
  "||"
  "!"
  "="
  "=>"
  "|>"
  ":"
  "|"
  "."
  ","
] @operator

; Punctuation
[
  "("
  ")"
  "{"
  "}"
  "["
  "]"
  "<"
  ">"
] @punctuation.bracket

; Literals
(integer) @number
(float) @number.float
(string) @string
(char) @character
(boolean) @boolean
(unit) @constant.builtin

; String interpolation
(interpolation
  "{" @punctuation.special
  "}" @punctuation.special)

(escape_sequence) @string.escape

; Types
(type_expression (identifier) @type)
(generic_type (identifier) @type)
(type_declaration name: (identifier) @type.definition)
(type_parameters (identifier) @type.parameter)

; Built-in types
((identifier) @type.builtin
  (#match? @type.builtin "^(Int|Float|Bool|String|Char|Unit|Option|Result|List)$"))

; Functions
(function_declaration name: (identifier) @function.definition)
(call_expression function: (identifier) @function.call)
(call_expression function: (member_expression member: (identifier) @function.method))

; Effect operations
(effect_declaration name: (identifier) @type.definition)
(effect_operation name: (identifier) @function.definition)
(handler_declaration name: (identifier) @function.definition)
(handler_declaration effect: (identifier) @type)
(handler_operation name: (identifier) @function.definition)

; Traits
(trait_declaration name: (identifier) @type.definition)
(trait_method name: (identifier) @function.definition)
(impl_declaration trait: (identifier) @type)

; Parameters
(parameter name: (identifier) @variable.parameter)

; Variables
(let_declaration name: (identifier) @variable.definition)
(identifier) @variable

; Patterns
(pattern (identifier) @variable)
(constructor_pattern name: (identifier) @constructor)
(field_pattern name: (identifier) @property)

; Record fields
(field_assignment name: (identifier) @property)
(record_field name: (identifier) @property)

; Member access
(member_expression member: (identifier) @property)

; Modules (capitalized identifiers used as module access)
(member_expression
  object: (identifier) @module
  (#match? @module "^[A-Z]"))

; Variants/Constructors (capitalized identifiers)
((identifier) @constructor
  (#match? @constructor "^[A-Z][a-zA-Z0-9]*$"))

; Special identifiers
((identifier) @constant.builtin
  (#match? @constant.builtin "^(None|Some|Ok|Err|true|false)$"))

; Property annotations
(property_clause (identifier) @attribute)
