diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2015-12-06 11:34:19 +0100 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2015-12-06 11:34:19 +0100 | 
| commit | 938a2f1667820c0ac9d5b08d4118aaf53e76a0cb (patch) | |
| tree | 0103bc2d8fa8c4b751c08a6d5a72b78c843aee6a | |
| parent | 303b3f1b434f26f936c241789c84dca6e2f50df2 (diff) | |
| download | vim-polyglot-938a2f1667820c0ac9d5b08d4118aaf53e76a0cb.tar.gz vim-polyglot-938a2f1667820c0ac9d5b08d4118aaf53e76a0cb.zip | |
Add vcl syntax, closes #82
| -rw-r--r-- | README.md | 1 | ||||
| -rwxr-xr-x | build | 1 | ||||
| -rw-r--r-- | ftdetect/polyglot.vim | 4 | ||||
| -rw-r--r-- | syntax/vcl.vim | 110 | 
4 files changed, 116 insertions, 0 deletions
| @@ -92,6 +92,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo  - [typescript](https://github.com/leafgarland/typescript-vim) (syntax, indent, compiler, ftplugin, ftdetect)  - [vala](https://github.com/tkztmk/vim-vala) (syntax, indent, ftdetect)  - [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax) +- [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax, ftdetect)  - [vm](https://github.com/lepture/vim-velocity) (syntax, indent, ftdetect)  - [xls](https://github.com/vim-scripts/XSLT-syntax) (syntax)  - [yard](https://github.com/sheerun/vim-yardoc) (syntax) @@ -163,6 +163,7 @@ PACKS="    typescript:leafgarland/typescript-vim    vala:tkztmk/vim-vala    vbnet:vim-scripts/vbnet.vim +  vcl:smerrill/vcl-vim-plugin    vm:lepture/vim-velocity    xls:vim-scripts/XSLT-syntax    yard:sheerun/vim-yardoc diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index ae2d8a4a..65650431 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -406,6 +406,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vala') == -1  autocmd BufRead *.vala,*.vapi set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m  au BufRead,BufNewFile *.vala,*.vapi setfiletype vala  endif +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vcl') == -1 +   +au BufRead,BufNewFile *.vcl set filetype=vcl +endif  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vm') == -1  au BufRead,BufNewFile *.vm set ft=velocity syntax=velocity diff --git a/syntax/vcl.vim b/syntax/vcl.vim new file mode 100644 index 00000000..3bd91a5c --- /dev/null +++ b/syntax/vcl.vim @@ -0,0 +1,110 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vcl') == -1 +   +" Vim syntax file +" Filename:     vcl.vim +" Language:     Varnish configuation Language, http://www.varnish-cache.org/wiki/VCL +" Maintainer:   Elan Ruusamäe <glen@delfi.ee> +" Version Info: $Revision: 1.7 $ +" Last Change:  $Date: 2010/04/06 08:24:28 $ UTC + +" 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 + +" TODO +" - sub ... +" - backend/director/... +" - acl ... +" - error when invalid operator used in if (...) +" - +=, = operators +" - functions + +" Code Blocks +"       sub NAME { +"       backend NAME { +"       director NAME FLAGS { +"       acl NAME { +"syn region vclCodeBlock start="\s*\<sub\|backend\|director\|acl\>" end="{"he=e-1 contains=vclCodeBlockName,vclFunctionName +"syn match  vclCodeBlockName "\<sub\|backend\|director\|acl\>" contained +"syn match  vclFunctionName "\h[[:alnum:]_:]*" contained +"syn match  vclFunctionName "\h\w*[^:]" contained +" +syn keyword vclOperator     set call return error esi synthetic include remove unset +" return modes +syn keyword vclModes        deliver pipe pass hash lookup discard fetch restart + +" C strings +syn region vclString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=vclSpecial +syn match  vclSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" +syn match  vclSpecialError   "L\='\\[^'\"?\\abfnrtv]'" +syn match  vclSpecialCharacter "L\='\\['\"?\\abfnrtv]'" +syn match  vclSpecialCharacter display "L\='\\\o\{1,3}'" +syn match  vclSpecialCharacter display "'\\x\x\{1,2}'" +syn match  vclSpecialCharacter display "L'\\x\x\+'" + +syn keyword vclConditional  if else elsif elseif + +" Numbers +syn match  vclNumbers  display transparent "\<\d\|\.\d" contains=vclNumber,vclNumberTime +syn match  vclNumber   display contained "\d\+" +" set obj.ttl = 0s, 0m; +syn match  vclNumberTime   display contained "\d\+[dhsm]" + +" client +syn match  vclOption   /client\.\(ip\|identity\)/ +" server +syn match  vclOption   /server\.\(ip\|port\)/ +" req +syn match  vclOption   /req\.\(hash\|request\|method\|url\|proto\|backend\healthy\|backend\|grace\|xid\|restarts\)/ +" bereq +syn match  vclOption   /bereq\.\(request\|method\|url\|proto\|connect_timeout\|first_byte_timeout\|between_bytes_timeout\)/ +" beresp +syn match  vclOption   /beresp\.\(proto\|status\|response\|cacheable\|ttl\|lastuse\|hits\|hash\|grace\|prefetch\|saintmode\|keep\)/ +" obj +syn match  vclOption   /obj\.\(proto\|status\|response\|cacheable\|ttl\|lastuse\|hits\|hash\|grace\|prefetch\)/ +" resp +syn match  vclOption   /resp\.\(proto\|status\|response\)/ +" common: http.HEADERNAME +syn match  vclOption   /\(req\|bereq\|resp\|beresp\|obj\)\.http\.[A-Za-z][-_A-Za-z0-9]*/ + +" Highlight the C block +syn include @vclC syntax/c.vim +unlet b:current_syntax + +" Mark block tags itself as comment +syn region vclCBlock matchgroup=vclComment start=/C{/ end=/}C/ contains=@vclC keepend + +" Synthetic +syn region vclSynthetic start=/{"/hs=s+2 end=/"}/he=e-2 contains=@vclHTML keepend + +" Allow html in synthetic +syn include @vclHTML syntax/html.vim +unlet b:current_syntax + +syn match  vclComment   '#.*' +syn match  vclComment   "//.*" +syn region vclComment    start="/\*"  end="\*/" + +syn sync ccomment vclComment + +hi link vclCodeBlock        Function +hi link vclComment          Comment +hi link vclStatement        Statement +hi link vclFunctionName     Identifier +hi link vclCodeBlockName    Statement +hi link vclSpecial          SpecialChar +hi link vclString           String +hi link vclConditional      Conditional +hi link vclSynthetic        vclString +hi link vclSpecialCharacter vclSpecialSpecial +hi link vclOperator         Operator +hi link vclModes            Operator +hi link vclOption           Identifier +hi link vclNumber           Number +hi link vclNumberTime       Number + +endif | 
