Skip to content

Instantly share code, notes, and snippets.

@dotxnc
Created February 24, 2025 05:03
Show Gist options
  • Save dotxnc/3e26cafaf01cc9390123ead780384997 to your computer and use it in GitHub Desktop.
Save dotxnc/3e26cafaf01cc9390123ead780384997 to your computer and use it in GitHub Desktop.
" Quit when a syntax file was already loaded
if exists("b:current_syntax")
finish
endif
" Keywords - Features
" Match the feature keyword and capture the identifier after it
syntax keyword hyperFeature behavior def eventsource js init on socket worker if then else end nextgroup=hyperIdentifier skipwhite
syntax match hyperIdentifier "\v[a-zA-Z_][a-zA-Z0-9_]*" contained
" Handle 'set' keyword and the variable name that follows it
syntax keyword hyperSet set nextgroup=hyperSetVariable skipwhite
syntax match hyperSetVariable "\v[a-zA-Z_][a-zA-Z0-9_]*" contained
" Rest of the syntax definitions...
syntax keyword hyperCommand add append async beep break call get continue decrement exit
syntax keyword hyperCommand fetch go halt hide if increment log make measure pick
syntax keyword hyperCommand put remove repeat return send trigger settle show
syntax keyword hyperCommand take tell throw toggle transition wait
" Keywords - Magic Values
syntax keyword hyperMagic it me you
" Operators and special characters
syntax match hyperOperator "\v\=\=" contained
syntax match hyperOperator "\v\-\>" contained
syntax match hyperOperator "\v\+" contained
syntax match hyperOperator "\v\-" contained skipwhite skipempty nextgroup=hyperComment
syntax match hyperOperator "\v\*" contained
syntax match hyperOperator "\v\/" contained
" String literals
syntax region hyperString start=/"/ skip=/\\"/ end=/"/ contains=hyperMagic
syntax region hyperString start=/`/ skip=/\\`/ end=/`/ contains=hyperMagic
syntax region hyperString start=/'/ skip=/\\'/ end=/'/ contains=hyperMagic
" Numbers
syntax match hyperNumber "\v<\d+>"
syntax match hyperNumber "\v<\d+\.\d+>"
syntax match hyperNumber "\v<\d+ms>"
syntax match hyperNumber "\v<\d+s>"
" Boolean literals
syntax keyword hyperBoolean true false
" Comments
syntax match hyperComment "\v--.*$"
" Element references
syntax match hyperElement "\v\<[^>]+\>"
syntax match hyperClass "\v\.[a-zA-Z][a-zA-Z0-9_-]*"
syntax match hyperClass "\v\@[a-zA-Z][a-zA-Z0-9_-]*"
syntax match hyperId "\v\#[a-zA-Z][a-zA-Z0-9_-]*"
" Time expressions
syntax match hyperTime "\v\d+(ms|s)"
" Function calls
syntax match hyperFunction "\v[a-zA-Z_][a-zA-Z0-9_]*\(" contains=hyperFunctionName
syntax match hyperFunctionName "\v[a-zA-Z_][a-zA-Z0-9_]*" contained
" Block structure
syntax keyword hyperBlock then end contained
syntax region hyperBlockRegion start=/\v(if|repeat)>/ end=/\vend>/ contains=ALL
" Match variables inside #{}
syntax match hyperVariable "\v#\{[^}]+\}"
" Match variables inside ${}
syntax match hyperVariable "\v\$\{[^}]+\}"
" Link syntax groups to standard highlighting groups
highlight default link hyperComment Comment
highlight default link hyperFeature Statement
highlight default link hyperMagic Special
highlight default link hyperIdentifier Function
highlight default link hyperCommand Keyword
highlight default link hyperOperator Operator
highlight default link hyperString String
highlight default link hyperNumber Number
highlight default link hyperBoolean Boolean
highlight default link hyperComment Comment
highlight default link hyperElement Tag
highlight default link hyperClass Type
highlight default link hyperId Identifier
highlight default link hyperTime Number
highlight default link hyperFunction Function
highlight default link hyperFunctionName Function
highlight default link hyperBlock Keyword
highlight default link hyperSet Keyword
highlight default link hyperVariable Function
highlight default link hyperSetVariable Function
let b:current_syntax = "hyperscript"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment