" Vim syntax file " Language: Mars " Maintainer: Matt Giuca " Updated: 2010-3-16 " Based on Python syntax by Neil Schemenauer " " To get vim to auto-detect .mar files: " Add to ~/.vim/after/filetype.vim: " au BufRead,BufNewFile *.mar set filetype=mars " " inside your augroup. For example: " " augroup filetypedetect " au BufRead,BufNewFile *.mar set filetype=mars " augroup END " " Options to control Mars syntax highlighting: " " For highlighted numbers: " " let mars_highlight_numbers = 1 " " For highlighted builtin functions: " " let mars_highlight_builtins = 1 " " Highlight erroneous whitespace: " " let mars_highlight_space_errors = 1 " " If you want all possible Mars highlighting (the same as setting the " preceding options): " " let mars_highlight_all = 1 " " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif syn keyword marsStatement return pass syn keyword marsStatement def nextgroup=marsFunction skipwhite syn match marsFunction "[a-z_][a-zA-Z0-9_]*" contained syn keyword marsTypedef type nextgroup=marsTypeName skipwhite syn match marsTypeName "[A-Z_][a-zA-Z0-9_]*" contained syn keyword marsStatement var nextgroup=marsDecl skipwhite syn match marsDecl "[a-z_][a-zA-Z0-9_]*" contained syn keyword marsRepeat while syn keyword marsConditional if else switch case "syn keyword marsOperator and in is not or syn keyword marsInclude import syn match marsComment "#.*$" contains=marsTodo,@Spell syn keyword marsTodo TODO FIXME XXX contained " Special symbols syn match marsSymbol "::" " strings syn region marsString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=marsEscape,@Spell syn region marsString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=marsEscape,@Spell syn region marsString matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=marsEscape,@Spell syn region marsString matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=marsEscape,@Spell syn region marsRawString matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+ contains=@Spell syn region marsRawString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell syn region marsRawString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+ contains=@Spell syn region marsRawString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+ contains=@Spell syn match marsEscape +\\[abfnrtv'"\\]+ contained syn match marsEscape "\\\o\{1,3}" contained syn match marsEscape "\\x\x\{2}" contained syn match marsEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained syn match marsEscape "\\$" if exists("mars_highlight_all") let mars_highlight_numbers = 1 let mars_highlight_builtins = 1 let mars_highlight_space_errors = 1 endif if exists("mars_highlight_numbers") " numbers (including longs and complex) syn match marsNumber "\<0x\x\+[Ll]\=\>" syn match marsNumber "\<\d\+[LljJ]\=\>" syn match marsNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" syn match marsNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>" syn match marsNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" endif if exists("mars_highlight_builtins") " builtin functions, types and objects, not really part of the syntax syn keyword marsBuiltinType Int Array syn keyword marsBuiltin eq cmp syn keyword marsBuiltin add sub mul div mod syn keyword marsBuiltin array array_ref __impure_array_set array_replace syn keyword marsBuiltin array_length __impure_array_append syn keyword marsBuiltin __impure_array_extend array_add array_concat syn keyword marsBuiltin __impure_array_delete array_remove syn keyword marsBuiltin put_char get_char get_env syn keyword marsBuiltin show error endif if exists("mars_highlight_space_errors") " trailing whitespace syn match marsSpaceError display excludenl "\S\s\+$"ms=s+1 " mixed tabs and spaces syn match marsSpaceError display " \+\t" syn match marsSpaceError display "\t\+ " endif " This is fast but code inside triple quoted strings screws it up. It " is impossible to fix because the only way to know if you are inside a " triple quoted string is to start from the beginning of the file. If " you have a fast machine you can try uncommenting the "sync minlines" " and commenting out the rest. syn sync match marsSync grouphere NONE "):$" syn sync maxlines=200 "syn sync minlines=2000 if version >= 508 || !exists("did_mars_syn_inits") if version <= 508 let did_mars_syn_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif " The default methods for highlighting. Can be overridden later HiLink marsStatement Statement HiLink marsFunction Function HiLink marsTypedef Typedef HiLink marsTypeName Type HiLink marsDecl Function HiLink marsConditional Conditional HiLink marsRepeat Repeat HiLink marsSymbol Operator HiLink marsString String HiLink marsRawString String HiLink marsEscape Special HiLink marsOperator Operator HiLink marsInclude Include HiLink marsComment Comment HiLink marsTodo Todo HiLink marsDecorator Define if exists("mars_highlight_numbers") HiLink marsNumber Number endif if exists("mars_highlight_builtins") HiLink marsBuiltinType Type HiLink marsBuiltin Function endif if exists("mars_highlight_space_errors") HiLink marsSpaceError Error endif delcommand HiLink endif let b:current_syntax = "mars" " vim: ts=8