Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions runtime/syntax/gleam.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
detect:
filename: "\\.gleam$"

rules:
# Keywords (from Gleam compiler token.rs)
- statement: "\\b(as|assert|auto|case|const|delegate|derive|echo|else|fn|if|implement|import|let|macro|opaque|panic|pub|test|todo|type|use)\\b"

# Built-in types (removed Nil - it is a constant)
- type: "\\b(Int|Float|String|Bool|List|Option|Result|BitArray)\\b"

# Constants
- constant: "\\b(True|False|Nil)\\b"

# Type constructors / Custom types (must come after built-in types)
- type: "\\b[A-Z][a-zA-Z0-9_]*\\b"

# Attributes (@external, @deprecated, @target, etc.)
- preproc: "@[a-z][a-z_]*"

# Operators (using statement for consistent coloring)
- statement: "(\\|>|->|<-)" # Pipe and arrow
- statement: "(\\.\\.|<>)" # Range and concat
- statement: "(==|!=|<=\\.|>=\\.|<\\.|>\\.|<=|>=)" # Comparison
- statement: "(&&|\\|\\|)" # Logical
- statement: "(\\+\\.|-\\.|\\*\\.|/\\.|\\+|-|\\*|/|%)" # Arithmetic
- statement: "(=|<|>|!|<<|>>)" # Other

# Numbers (from Python syntax with underscore support)
- constant.number: "\\b0b[01](_?[01])*\\b"
- constant.number: "\\b0o[0-7](_?[0-7])*\\b"
- constant.number: "\\b0x[0-9a-fA-F](_?[0-9a-fA-F])*\\b"
- constant.number: "\\b[0-9](_?[0-9])*(\\.[0-9](_?[0-9])*)?([eE][+-]?[0-9](_?[0-9])*)?\\b"

# Tuple syntax
- special: "#\\("

# Strings
- constant.string:
start: '"'
end: '"'
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."

# Comments
- comment:
start: "//"
end: "$"
rules:
- todo: "(TODO|FIXME|XXX):?"