summaryrefslogtreecommitdiffstats
path: root/syntax/velocity.vim
blob: 6a074de5c896bf9c7154100089d25c07827e8a99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
if has_key(g:polyglot_is_disabled, 'velocity')
  finish
endif

" Vim syntax file
" Language:	Velocity HTML template
" Maintainer:	Hsiaoming Young <http://lepture.com>
" Last Change:	2012 Jan 09

" 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

if !exists("main_syntax")
  let main_syntax = 'html'
endif

if version < 600
  so <sfile>:p:h/html.vim
else
  runtime! syntax/html.vim
  unlet b:current_syntax
endif

syn keyword velocityTodo FIXME TODO contained
syn region velocitySpec start="@" end=" " oneline contained
syn region velocityComment start="#\*" end="\*#" contains=velocityTodo,velocitySpec
syn match velocityComment /##.*/ contains=velocityTodo,velocitySpec
syn region velocityString start='"' end='"' oneline display
syn region velocityString start="'" end="'" oneline display
syn match velocityNumber "[-+]\=\d\+\(\.\d*\)\=" display
syn region velocityList start='\[' end='\]' oneline contained contains=velocityString,velocityNumber
syn match velocityMath /=\|-\|+\|\/\|\*\|%/ contained
syn match velocityBlock /#[a-z]\{2,\}/ contains=velocityStatement
syn match velocityBlock /#[a-z]\{2,\}(.\+)/ contains=velocityStatement,velocityVar,velocityString,velocityNumber,velocityMath,velocityList
syn keyword velocityStatement in set if else elseif end foreach include parse macro cmsparse stop break evaluate define contained

syn match velocityVar /$!\?[a-zA-Z][a-zA-Z0-9_-]\+\(\.\?[a-zA-Z0-9]*\)\+/ contains=velocityFunction display containedin=ALL
syn match velocityVar /$!\?{[a-zA-Z][a-zA-Z0-9_-]\+}/ display containedin=ALL
syn match velocityFunction /[a-zA-Z][a-zA-Z0-9_-]\+\(\.[a-zA-Z][a-zA-Z0-9_-]\+\)\+([^)]*)/ contains=velocityString,velocityNumber,velocityList,velocityMath,velocityVar,velocityFunction display containedin=velocityBlock

" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_velocity_syn_inits")
  if version < 508
    let did_velocity_syn_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  HiLink velocityString String
  HiLink velocityNumber Number
  HiLink velocityList Constant
  HiLink velocityBlock PreProc
  HiLink velocitySpec Special
  HiLink velocityVar Identifier
  HiLink velocityFunction Function
  HiLink velocityStatement Statement
  HiLink velocityComment Comment
  HiLink velocityTodo Todo

  delcommand HiLink
endif

let b:current_syntax = "velocity"