if exists("b:current_syntax")
  finish
endif

syntax clear

" =================[ Keywords (Orange) ]=================
syntax keyword muKeyword extend fn type include import return let const describe it expect_equal expect_not_equal has_key prop_equals test sput slog containedin=ALLBUT,muComment,muCommentBlock

" ================[ Booleans (Blue) ]====================
syntax keyword muBoolean true false containedin=ALLBUT,muComment,muCommentBlock

" ================[ Placeholder (Purple) ]================
syntax match muPlaceholder /\<_\>/ containedin=ALLBUT,muComment,muCommentBlock

" ================[ Strings (Green delimiters, Red content) ]===============
syntax region muString start=/"/ skip=/\\"/ end=/"/ contains=muStringContent containedin=ALLBUT,muComment,muCommentBlock
syntax region muString start=/'/ skip=/\\'/ end=/'/ contains=muStringContent containedin=ALLBUT,muComment,muCommentBlock
syntax region muString start=/`/ skip=/\\`/ end=/`/ contains=muStringContent containedin=ALLBUT,muComment,muCommentBlock
syntax match muStringContent /"\zs[^"]\+\ze"/ contained containedin=muString
syntax match muStringContent /'\zs[^']\+\ze'/ contained containedin=muString
syntax match muStringContent /`\zs[^`]\+\ze`/ contained containedin=muString

" ================[ Numbers (Orange-Brown) ]==============
syntax match muNumber /\<[0-9]\+\(\.[0-9]\+\)\?\>/ containedin=ALLBUT,muComment,muCommentBlock

" ================[ Comments (Dark gray) ]=================
syntax region muCommentBlock start="/\*" end="\*/" keepend contains=muCommentBlock
syntax match muComment /\/\/.*/ containedin=ALLBUT,muString,muCommentBlock
syntax match muComment /\#.*/ containedin=ALLBUT,muString,muCommentBlock

" ================[ Function Definitions (Bold Blue) ]========
syntax match muFunctionDef /^[ \t]*\zs\h\w*\ze[ \t]*=/ containedin=ALLBUT,muComment,muCommentBlock

" ================[ Function Calls (Bright Blue) ]============
syntax match muFunctionCall /\<[a-zA-Z_][a-zA-Z0-9_]*\s*(/ contained containedin=ALLBUT,muComment,muCommentBlock

" ================[ Arrow Function (Purple) ]=================
syntax match muFunctionArrow /=>/ containedin=ALLBUT,muComment,muCommentBlock

" ================[ Operators (Purple) ]======================
syntax match muOperator /[+*\/%^|&!~?:<>=-]\+/ containedin=ALLBUT,muComment,muCommentBlock
syntax match muAssignOperator /=\|:=/ containedin=ALLBUT,muComment,muCommentBlock

" ================[ Keyed Array Keys (Brown) ]=================
syntax match muKeyedKey /\<[a-zA-Z_][a-zA-Z0-9_]*\s*:/ containedin=ALLBUT,muString,muComment,muCommentBlock

" ================[ Parens/Brackets/Braces (Dark blue) ]=======
syntax match muBracket /[\[\]]/ containedin=ALLBUT,muComment,muCommentBlock
syntax match muParen /[()]/ containedin=ALLBUT,muComment,muCommentBlock
syntax match muBrace /[{}]/ containedin=ALLBUT,muComment,muCommentBlock

" =================[ Variables (Black) ]=====================
syntax match muVariable /\<[a-zA-Z_][a-zA-Z0-9_]*\>/ containedin=ALLBUT,muComment,muCommentBlock

" =========================[ Colors ]=========================
highlight default link muKeyword         Keyword
highlight default link muBoolean         Boolean
highlight default link muPlaceholder     Special
highlight default link muFunctionDef     Function
highlight default link muFunctionCall    Function
highlight default link muFunctionArrow   Operator
highlight default link muString          String
highlight default link muStringContent   Constant
highlight default link muNumber          Number
highlight default link muComment         Comment
highlight default link muCommentBlock    Comment
highlight default link muBracket         Structure
highlight default link muParen           Structure
highlight default link muBrace           Structure
highlight default link muOperator        Operator
highlight default link muAssignOperator  Operator
highlight default link muKeyedKey        Type

highlight muVariable guifg=#101010 ctermfg=black

if exists('+termguicolors') && &termguicolors
  highlight muKeyword         guifg=#f28b25 gui=bold
  highlight muBoolean         guifg=#0069e0 gui=bold
  highlight muPlaceholder     guifg=#a259de gui=bold
  highlight muFunctionDef     guifg=#2066cc gui=bold
  highlight muFunctionCall    guifg=#1d55a6 gui=bold
  highlight muFunctionArrow   guifg=#ae3ec9 gui=bold
  highlight muString          guifg=#3eb450 gui=bold
  highlight muStringContent   guifg=#e11e1e gui=bold
  highlight muNumber          guifg=#b5630b gui=bold
  highlight muComment         guifg=#545454 gui=italic
  highlight muCommentBlock    guifg=#545454 gui=italic
  highlight muBracket         guifg=#143861 gui=bold
  highlight muParen           guifg=#143861 gui=bold
  highlight muBrace           guifg=#143861 gui=bold
  highlight muOperator        guifg=#ae3ec9 gui=bold
  highlight muAssignOperator  guifg=#ae3ec9 gui=bold
  highlight muKeyedKey        guifg=#ad7f13 gui=bold
endif

let b:current_syntax = "mu"
