diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2015-06-11 17:02:51 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2015-06-11 17:02:51 +0200 | 
| commit | d1e95cbc98805f82024b318d8fd52e931a3aeae2 (patch) | |
| tree | 01aea78f2c57c94bf9c3b39bc604f86c6cb78bf7 /syntax | |
| parent | 7ffa793f199f457beac69fe4412734bd28dc0bbf (diff) | |
| download | vim-polyglot-d1e95cbc98805f82024b318d8fd52e931a3aeae2.tar.gz vim-polyglot-d1e95cbc98805f82024b318d8fd52e931a3aeae2.zip | |
Add julia and ragel syntaxv1.14.0
Diffstat (limited to 'syntax')
| -rw-r--r-- | syntax/julia.vim | 149 | ||||
| -rw-r--r-- | syntax/ragel.vim | 164 | 
2 files changed, 313 insertions, 0 deletions
| diff --git a/syntax/julia.vim b/syntax/julia.vim new file mode 100644 index 00000000..9dab3c86 --- /dev/null +++ b/syntax/julia.vim @@ -0,0 +1,149 @@ + +if exists("b:current_syntax") +  finish +endif + +syn case match + + +syn keyword juliaDirective import importall export using require include + +hi def link juliaDirective Include + +syn region juliaDeclTypeBlock transparent matchgroup=juliaDeclType start="\<\%(type\|immutable\)\>" end="\<end\>" contains=ALL +syn keyword juliaTypeAlias typealias +syn keyword juliaDeclAbstract abstract + +hi def link juliaDeclType  Structure +hi def link juliaTypeAlias Typedef +hi def link juliaDeclAbstract Structure + +" Module +syn region juliaModuleBlock transparent matchgroup=juliaModule start="\<module\>" end="\<end\>" contains=ALL + +hi def link juliaModule Structure + + +" Misc. blocks +syn region juliaMiscBlockBlock transparent matchgroup=juliaMiscBlock start="\<\%(quote\|do\|begin\|let\)\>" end="\<end\>" contains=ALL + +hi def link juliaMiscBlock Repeat + +" Braces and Brackets +syn region juliaBracketsBlock matchgroup=juliaBrackets start='\[' end='\]' contains=ALLBUT,juliaRepeatBlock contained +syn region juliaBracesBlock matchgroup=juliaBraces start='{' end='}' contains=ALLBUT,juliaRepeatBlock contained + +" Repeat +syn region juliaRepeatBlock transparent matchgroup=juliaRepeat start="\<\%(while\|for\)\>" end="\<end\>" contains=@juliaTop + +hi def link juliaRepeat    Repeat + +" Conditional +syn keyword juliaElse else elseif +syn region  juliaIfBlock transparent matchgroup=juliaIf start="\<if\>" end="\<end\>" contains=@juliaTop + +hi def link juliaElse Conditional +hi def link juliaIf   Conditional + + +" try catch end +syn keyword juliaCatch    catch contained +syn region  juliaTryBlock transparent matchgroup=juliaTry start="\<try\>" end="\<end\>" contains=@juliaTop + +hi def link juliaTry Exception +hi def link juliaCatch Exception + + +" one word statements +syn keyword juliaStatement return continue break + +hi def link juliaStatement Statement + +" misc +syn keyword juliaDeclaration const global local +syn keyword juliaComprehensionFor for + +hi def link juliaDeclaration Keyword +hi def link juliaComprehensionFor Keyword + +" Built in types +syn keyword juliaType Uint Uint8 Uint16 Uint32 Uint64 Uint128 +syn keyword juliaType Int Int8 Int16 Int32 Int64 Int128 +syn keyword juliaType Float Float16 Float32 Float64 +syn keyword juliaType AbstractArray AbstractMatrix AbstractVector Array Vector Matrix +syn keyword juliaType String ByteString UTF8String SubString +syn keyword juliaType Bool Nothing Union Type + + +hi def link juliaType Type + + +" Comments +syn keyword juliaTodo         contained TODO FIXME XXX +syn cluster juliaCommentGroup contains=juliaTodo +syn region  juliaComment      start="#" end="$" contains=@juliaCommentGroup,@Spell + +hi def link juliaComment Comment +hi def link juliaTodo    Todo + + +" Strings +syn region juliaString       start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@juliaStringGroup,@Spell +syn region juliaTripleString start=+"""+ end=+"""+ +syn region juliaCharacter    start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@juliaCharacterGroup + +hi def link juliaString        String +hi def link juliaTripleString  String +hi def link juliaCharacter     Character + + +" Functions +syn region juliaFunctionBlock transparent matchgroup=juliaFunction start="\<\%\(function\|macro\)\>" end="\<end\>" contains=@juliaTop +hi def link juliaFunction Function + + +" Numbers +syn match juliaNumber "\<\d\+\([Ee]\d\+\)\?\>" +syn match juliaNumber "\<0x\x\+\>" +syn match juliaNumber "\<0\o\+\>" + +syn match juliaFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" +syn match juliaFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" +syn match juliaFloat "\<\d\+[Ee][-+]\d\+\>" +syn keyword juliaFloatSpecial NaN Inf + +hi def link juliaNumber Number +hi def link juliaFloat Float +hi def link juliaFloatSpecial Float + + +" Operators +syn keyword juliaIn in +hi def link juliaIn Operator + + +" Constants +syn keyword juliaBool true false nothing +hi def link juliaBool Boolean + +syn keyword juliaIdentifierSpecial STDOUT, STDIN, STDERR + +hi def link juliaIdentifierSpecial Identifier + + +" Macros +syn match juliaMacro display "@[_[:alpha:]][_[:alnum:]!]*\%(\.[_[:alpha:]][_[:alnum:]!]*\)*" + +hi def link juliaMacro Macro + + +syn cluster juliaTop contains=ALLBUT,juliaComprehensionFor + +" Ragel +syn include @ragel syntax/ragel.vim +syn region ragelLine  start="%%" end="$" contains=@ragel + + +let b:current_syntax = "julia" + + diff --git a/syntax/ragel.vim b/syntax/ragel.vim new file mode 100644 index 00000000..67ade168 --- /dev/null +++ b/syntax/ragel.vim @@ -0,0 +1,164 @@ +" Vim syntax file +" +" Language: Ragel +" Author: Adrian Thurston + +syntax clear + +if !exists("g:ragel_default_subtype") +  let g:ragel_default_subtype = 'c' +endif + +function! <SID>Split(path) abort " {{{1 +  if type(a:path) == type([]) | return a:path | endif +  let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,') +  return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")') +endfunction " }}}1 + +fun! <SID>ReadOnPath(script) +  for dir in <SID>Split(&rtp) +    let filepath = dir.'/'.a:script +    if filereadable(filepath) +      return join(readfile(filepath), " | ") +    endif +  endfor +endfun + +" Try to detect the subtype. stolen from eruby.vim +if !exists("b:ragel_subtype") || b:ragel_subtype == '' +  " first check for an annotation in the first 5 lines or on the last line +  let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") +  let b:ragel_subtype = matchstr(s:lines, 'ragel_subtype=\zs\w\+') + +  " failing that, check the filename for .*.rl +  if b:ragel_subtype == '' +    let b:ragel_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.rl\|\.ragel\)\+$','',''),'\.\zs\w\+$') + +    " ...and do a couple of transformations if necessary + +    " .rb -> ruby +    if b:ragel_subtype == 'rb' +      let b:ragel_subtype = 'ruby' + +    " .m -> objc +    elseif b:ragel_subtype == 'm' +      let b:ragel_subtype = 'objc' +     +    " .cxx -> cpp +    elseif b:ragel_subtype == 'cxx' +      let b:ragel_subtype = 'cpp' +    endif +  endif + +  " default to g:ragel_default_subtype +  if b:ragel_subtype == '' +    let b:ragel_subtype = g:ragel_default_subtype +  endif +endif + +if exists('b:ragel_subtype') && b:ragel_subtype != '' +  exec 'runtime! syntax/'.b:ragel_subtype.'.vim' +  " source s:subtype_file +  unlet! b:current_syntax +endif + +" Identifiers +syntax match anyId "[a-zA-Z_][a-zA-Z_0-9]*" contained + +" Inline code only +syntax keyword fsmType fpc fc fcurs fbuf fblen ftargs fstack contained +syntax keyword fsmKeyword fhold fgoto fcall fret fentry fnext fexec fbreak contained + +syntax cluster rlItems contains=rlComment,rlLiteral,rlAugmentOps,rlOtherOps,rlKeywords,rlWrite,rlCodeCurly,rlCodeSemi,rlNumber,anyId,rlLabelColon,rlExprKeywords + +syntax region machineSpec1 matchgroup=beginRL start="%%{" end="}%%" contains=@rlItems +syntax region machineSpec2 matchgroup=beginRL start="%%[^{]"rs=e-1 end="$" keepend contains=@rlItems +syntax region machineSpec2 matchgroup=beginRL start="%%$" end="$" keepend contains=@rlItems + +" Comments +syntax match rlComment "#.*$" contained + +" Literals +" single quoted strings  '...' +  syntax match rlLiteral "'\(\\.\|[^'\\]\)*'[i]*" contained +" double quoted strings  "..." +  syntax match rlLiteral "\"\(\\.\|[^\"\\]\)*\"[i]*" contained +" simple regexes         /.../ +  syntax match rlLiteral /\/\(\\.\|[^\/\\]\)*\/[i]*/ contained +" char unions            [...] +  syntax match rlLiteral "\[\(\\.\|[^\]\\]\)*\]" contained + +" Numbers +syntax match rlNumber "[0-9][0-9]*" contained +syntax match rlNumber "0x[0-9a-fA-F][0-9a-fA-F]*" contained + +" Operators +syntax match rlAugmentOps "[>$%@]" contained +syntax match rlAugmentOps "<>\|<" contained +syntax match rlAugmentOps "[>\<$%@][!\^/*~]" contained +syntax match rlAugmentOps "[>$%]?" contained +syntax match rlAugmentOps "<>[!\^/*~]" contained +syntax match rlAugmentOps "=>" contained +syntax match rlOtherOps "->" contained + +syntax match rlOtherOps ":>" contained +syntax match rlOtherOps ":>>" contained +syntax match rlOtherOps "<:" contained + +" Keywords +" FIXME: Enable the range keyword post 5.17. +" syntax keyword rlKeywords machine action context include range contained +syntax keyword rlKeywords machine action context include import export prepush postpop contained +syntax keyword rlExprKeywords when inwhen outwhen err lerr eof from to contained + +" Case Labels +syntax keyword caseLabelKeyword case contained +syntax cluster caseLabelItems contains=caseLabelKeyword,anyId,fsmType,fsmKeyword +syntax match caseLabelColon "case" contains=@caseLabelItems contained +syntax match caseLabelColon "case[\t ]\+.*:$" contains=@caseLabelItems contained +syntax match caseLabelColon "case[\t ]\+.*:[^=:]"me=e-1 contains=@caseLabelItems contained + +syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:$" contained contains=anyLabel +syntax match rlLabelColon "[a-zA-Z_][a-zA-Z_0-9]*[ \t]*:[^=:>]"me=e-1 contained contains=anyLabel +syntax match anyLabel "[a-zA-Z_][a-zA-Z_0-9]*" contained + +" All items that can go in a code block. + +syntax cluster inlineItems contains=TOP add=anyId,fsmType,fsmKeyword,caseLabelColon + +" Blocks of code. rlCodeCurly is recursive. +syntax region rlCodeCurly matchgroup=NONE start="{" end="}" keepend contained contains=TOP +syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems + +syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions + +syntax keyword rlWriteKeywords init data exec exports start error first_final contained +syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained + +" +" Sync at the start of machine specs. +" +" Match The ragel delimiters only if there quotes no ahead on the same line. +" On the open marker, use & to consume the leader. +syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%{&^[^\'\"%]*" +syntax sync match ragelSyncPat grouphere NONE "^[^\'\"%]*%%[^{]&^[^\'\"%]*" +syntax sync match ragelSyncPat grouphere NONE "^[^\'\"]*}%%" + +" +" Specifying Groups +" +hi link rlComment Comment +hi link rlNumber Number +hi link rlLiteral String +hi link rlAugmentOps Keyword +hi link rlExprKeywords Keyword +hi link rlWriteKeywords Keyword +hi link rlWriteOptions Keyword +hi link rlKeywords Type +hi link fsmType Type +hi link fsmKeyword Keyword +hi link anyLabel Label +hi link caseLabelKeyword Keyword +hi link beginRL Type +  +let b:current_syntax = "ragel" | 
