comparison .vim/syntax/django.vim @ 0:c30d68fbd368

Initial import from svn.
author Augie Fackler <durin42@gmail.com>
date Wed, 26 Nov 2008 10:56:09 -0600
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c30d68fbd368
1 " Vim syntax file
2 " Language: Django template
3 " Maintainer: Dave Hodder <dmh@dmh.org.uk>
4 " Last Change: 2007 Apr 21
5
6 " For version 5.x: Clear all syntax items
7 " For version 6.x: Quit when a syntax file was already loaded
8 if version < 600
9 syntax clear
10 elseif exists("b:current_syntax")
11 finish
12 endif
13
14 syntax case match
15
16 " Mark illegal characters
17 syn match djangoError "%}\|}}\|#}"
18
19 " Django template built-in tags and parameters
20 " 'comment' doesn't appear here because it gets special treatment
21 syn keyword djangoStatement contained and as block endblock by cycle debug else
22 syn keyword djangoStatement contained extends filter endfilter firstof for
23 syn keyword djangoStatement contained endfor if endif ifchanged endifchanged
24 syn keyword djangoStatement contained ifequal endifequal ifnotequal
25 syn keyword djangoStatement contained endifnotequal in include load not now or
26 syn keyword djangoStatement contained parsed regroup reversed spaceless
27 syn keyword djangoStatement contained endspaceless ssi templatetag openblock
28 syn keyword djangoStatement contained closeblock openvariable closevariable
29 syn keyword djangoStatement contained openbrace closebrace opencomment
30 syn keyword djangoStatement contained closecomment widthratio url with endwith
31 syn keyword djangoStatement contained get_current_language trans noop blocktrans
32 syn keyword djangoStatement contained endblocktrans get_available_languages
33 syn keyword djangoStatement contained get_current_language_bidi plural
34
35 " Django templete built-in filters
36 syn keyword djangoFilter contained add addslashes capfirst center cut date
37 syn keyword djangoFilter contained default default_if_none dictsort
38 syn keyword djangoFilter contained dictsortreversed divisibleby escape
39 syn keyword djangoFilter contained filesizeformat first fix_ampersands
40 syn keyword djangoFilter contained floatformat get_digit join length length_is
41 syn keyword djangoFilter contained linebreaks linebreaksbr linenumbers ljust
42 syn keyword djangoFilter contained lower make_list phone2numeric pluralize
43 syn keyword djangoFilter contained pprint random removetags rjust slice slugify
44 syn keyword djangoFilter contained stringformat striptags
45 syn keyword djangoFilter contained time timesince timeuntil title
46 syn keyword djangoFilter contained truncatewords unordered_list upper urlencode
47 syn keyword djangoFilter contained urlize urlizetrunc wordcount wordwrap yesno
48
49 " Keywords to highlight within comments
50 syn keyword djangoTodo contained TODO FIXME XXX
51
52 " Django template constants (always surrounded by double quotes)
53 syn region djangoArgument contained start=/"/ skip=/\\"/ end=/"/
54
55 " Mark illegal characters within tag and variables blocks
56 syn match djangoTagError contained "#}\|{{\|[^%]}}\|[<>!&#]"
57 syn match djangoVarError contained "#}\|{%\|%}\|[<>!&#%]"
58
59 " Django template tag and variable blocks
60 syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display
61 syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display
62
63 " Django template 'comment' tag and comment block
64 syn region djangoComment start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}" contains=djangoTodo
65 syn region djangoComBlock start="{#" end="#}" contains=djangoTodo
66
67 " Define the default highlighting.
68 " For version 5.7 and earlier: only when not done already
69 " For version 5.8 and later: only when an item doesn't have highlighting yet
70 if version >= 508 || !exists("did_django_syn_inits")
71 if version < 508
72 let did_django_syn_inits = 1
73 command -nargs=+ HiLink hi link <args>
74 else
75 command -nargs=+ HiLink hi def link <args>
76 endif
77
78 HiLink djangoTagBlock PreProc
79 HiLink djangoVarBlock PreProc
80 HiLink djangoStatement Statement
81 HiLink djangoFilter Identifier
82 HiLink djangoArgument Constant
83 HiLink djangoTagError Error
84 HiLink djangoVarError Error
85 HiLink djangoError Error
86 HiLink djangoComment Comment
87 HiLink djangoComBlock Comment
88 HiLink djangoTodo Todo
89
90 delcommand HiLink
91 endif
92
93 let b:current_syntax = "django"