if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'moonscript') == -1 " Language: MoonScript " Maintainer: leafo " Based On: CoffeeScript by Mick Koch " URL: http://github.com/leafo/moonscript-vim " License: WTFPL " Bail if our syntax is already loaded. if exists('b:current_syntax') && b:current_syntax == 'moon' finish endif if version < 600 syn clear endif " Highlight long strings. syn sync minlines=100 " These are `matches` instead of `keywords` because vim's highlighting " priority for keywords is higher than matches. This causes keywords to be " highlighted inside matches, even if a match says it shouldn't contain them -- " like with moonAssign and moonDot. syn match moonStatement /\<\%(return\|break\|continue\)\>/ display hi def link moonStatement Statement syn match moonRepeat /\<\%(for\|while\)\>/ display hi def link moonRepeat Repeat syn match moonConditional /\<\%(if\|else\|elseif\|then\|switch\|when\|unless\)\>/ \ display hi def link moonConditional Conditional " syn match moonException /\<\%(try\|catch\|finally\)\>/ display " hi def link moonException Exception syn match moonKeyword /\<\%(export\|local\|import\|from\|with\|in\|and\|or\|not\|class\|extends\|super\|using\|do\)\>/ \ display hi def link moonKeyword Keyword " all built in funcs from Lua 5.1 syn keyword moonLuaFunc assert collectgarbage dofile error next syn keyword moonLuaFunc print rawget rawset tonumber tostring type _VERSION syn keyword moonLuaFunc _G getfenv getmetatable ipairs loadfile syn keyword moonLuaFunc loadstring pairs pcall rawequal syn keyword moonLuaFunc require setfenv setmetatable unpack xpcall syn keyword moonLuaFunc load module select syn match moonLuaFunc /package\.cpath/ syn match moonLuaFunc /package\.loaded/ syn match moonLuaFunc /package\.loadlib/ syn match moonLuaFunc /package\.path/ syn match moonLuaFunc /package\.preload/ syn match moonLuaFunc /package\.seeall/ syn match moonLuaFunc /coroutine\.running/ syn match moonLuaFunc /coroutine\.create/ syn match moonLuaFunc /coroutine\.resume/ syn match moonLuaFunc /coroutine\.status/ syn match moonLuaFunc /coroutine\.wrap/ syn match moonLuaFunc /coroutine\.yield/ syn match moonLuaFunc /string\.byte/ syn match moonLuaFunc /string\.char/ syn match moonLuaFunc /string\.dump/ syn match moonLuaFunc /string\.find/ syn match moonLuaFunc /string\.len/ syn match moonLuaFunc /string\.lower/ syn match moonLuaFunc /string\.rep/ syn match moonLuaFunc /string\.sub/ syn match moonLuaFunc /string\.upper/ syn match moonLuaFunc /string\.format/ syn match moonLuaFunc /string\.gsub/ syn match moonLuaFunc /string\.gmatch/ syn match moonLuaFunc /string\.match/ syn match moonLuaFunc /string\.reverse/ syn match moonLuaFunc /table\.maxn/ syn match moonLuaFunc /table\.concat/ syn match moonLuaFunc /table\.sort/ syn match moonLuaFunc /table\.insert/ syn match moonLuaFunc /table\.remove/ syn match moonLuaFunc /math\.abs/ syn match moonLuaFunc /math\.acos/ syn match moonLuaFunc /math\.asin/ syn match moonLuaFunc /math\.atan/ syn match moonLuaFunc /math\.atan2/ syn match moonLuaFunc /math\.ceil/ syn match moonLuaFunc /math\.sin/ syn match moonLuaFunc /math\.cos/ syn match moonLuaFunc /math\.tan/ syn match moonLuaFunc /math\.deg/ syn match moonLuaFunc /math\.exp/ syn match moonLuaFunc /math\.floor/ syn match moonLuaFunc /math\.log/ syn match moonLuaFunc /math\.log10/ syn match moonLuaFunc /math\.max/ syn match moonLuaFunc /math\.min/ syn match moonLuaFunc /math\.fmod/ syn match moonLuaFunc /math\.modf/ syn match moonLuaFunc /math\.cosh/ syn match moonLuaFunc /math\.sinh/ syn match moonLuaFunc /math\.tanh/ syn match moonLuaFunc /math\.pow/ syn match moonLuaFunc /math\.rad/ syn match moonLuaFunc /math\.sqrt/ syn match moonLuaFunc /math\.frexp/ syn match moonLuaFunc /math\.ldexp/ syn match moonLuaFunc /math\.random/ syn match moonLuaFunc /math\.randomseed/ syn match moonLuaFunc /math\.pi/ syn match moonLuaFunc /io\.stdin/ syn match moonLuaFunc /io\.stdout/ syn match moonLuaFunc /io\.stderr/ syn match moonLuaFunc /io\.close/ syn match moonLuaFunc /io\.flush/ syn match moonLuaFunc /io\.input/ syn match moonLuaFunc /io\.lines/ syn match moonLuaFunc /io\.open/ syn match moonLuaFunc /io\.output/ syn match moonLuaFunc /io\.popen/ syn match moonLuaFunc /io\.read/ syn match moonLuaFunc /io\.tmpfile/ syn match moonLuaFunc /io\.type/ syn match moonLuaFunc /io\.write/ syn match moonLuaFunc /os\.clock/ syn match moonLuaFunc /os\.date/ syn match moonLuaFunc /os\.difftime/ syn match moonLuaFunc /os\.execute/ syn match moonLuaFunc /os\.exit/ syn match moonLuaFunc /os\.getenv/ syn match moonLuaFunc /os\.remove/ syn match moonLuaFunc /os\.rename/ syn match moonLuaFunc /os\.setlocale/ syn match moonLuaFunc /os\.time/ syn match moonLuaFunc /os\.tmpname/ syn match moonLuaFunc /debug\.debug/ syn match moonLuaFunc /debug\.gethook/ syn match moonLuaFunc /debug\.getinfo/ syn match moonLuaFunc /debug\.getlocal/ syn match moonLuaFunc /debug\.getupvalue/ syn match moonLuaFunc /debug\.setlocal/ syn match moonLuaFunc /debug\.setupvalue/ syn match moonLuaFunc /debug\.sethook/ syn match moonLuaFunc /debug\.traceback/ syn match moonLuaFunc /debug\.getfenv/ syn match moonLuaFunc /debug\.getmetatable/ syn match moonLuaFunc /debug\.getregistry/ syn match moonLuaFunc /debug\.setfenv/ syn match moonLuaFunc /debug\.setmetatable/ hi def link moonLuaFunc Identifier " The first case matches symbol operators only if they have an operand before. syn match moonExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?#]\+\|\.\|\\/ \ display hi def link moonExtendedOp moonOperator hi def link moonOperator Operator syntax match moonFunction /->\|=>\|)\|(\|\[\|]\|{\|}\|!/ highlight default link moonFunction Function " This is separate from `moonExtendedOp` to help differentiate commas from " dots. syn match moonSpecialOp /[,;]/ display hi def link moonSpecialOp SpecialChar syn match moonBoolean /\<\%(true\|false\)\>/ display hi def link moonBoolean Boolean syn match moonGlobal /\<\%(nil\)\>/ display hi def link moonGlobal Type " A special variable syn match moonSpecialVar /\<\%(self\)\>/ display " An @-variable syn match moonSpecialVar /@\%(\I\i*\)\?/ display hi def link moonSpecialVar Structure " A class-like name that starts with a capital letter syn match moonObject /\<\u\w*\>/ display hi def link moonObject Structure " A constant-like name in SCREAMING_CAPS syn match moonConstant /\<\u[A-Z0-9_]\+\>/ display hi def link moonConstant Constant " A variable name syn cluster moonIdentifier contains=moonSpecialVar,moonObject, \ moonConstant " A non-interpolated string syn cluster moonBasicString contains=@Spell,moonEscape " An interpolated string syn cluster moonInterpString contains=@moonBasicString,moonInterp " Regular strings syn region moonString start=/"/ skip=/\\\\\|\\"/ end=/"/ \ contains=@moonInterpString syn region moonString start=/'/ skip=/\\\\\|\\'/ end=/'/ \ contains=@moonBasicString hi def link moonString String syn region moonString2 matchgroup=moonString start="\[\z(=*\)\[" end="\]\z1\]" contains=@Spell hi def link moonString2 String " A integer, including a leading plus or minus syn match moonNumber /\i\@/ display hi def link moonNumber Number " A floating-point number, including a leading plus or minus syn match moonFloat /\i\@/ \ display hi def link moonReservedError Error endif " This is separate from `moonExtendedOp` since assignments require it. syn match moonAssignOp /:/ contained display hi def link moonAssignOp moonOperator " Strings used in string assignments, which can't have interpolations syn region moonAssignString start=/"/ skip=/\\\\\|\\"/ end=/"/ contained \ contains=@moonBasicString syn region moonAssignString start=/'/ skip=/\\\\\|\\'/ end=/'/ contained \ contains=@moonBasicString hi def link moonAssignString String " A normal object assignment syn match moonObjAssign /@\?\I\i*\s*:\@