xref: /vim-8.2.3635/runtime/syntax/django.vim (revision 5f1920ad)
1" Vim syntax file
2" Language:	Django template
3" Maintainer:	Dave Hodder <[email protected]>
4" Last Change:	2014 Jul 13
5
6" quit when a syntax file was already loaded
7if exists("b:current_syntax")
8  finish
9endif
10
11syntax case match
12
13" Mark illegal characters
14syn match djangoError "%}\|}}\|#}"
15
16" Django template built-in tags and parameters
17" 'comment' doesn't appear here because it gets special treatment
18syn keyword djangoStatement contained autoescape csrf_token empty
19" FIXME ==, !=, <, >, <=, and >= should be djangoStatements:
20" syn keyword djangoStatement contained == != < > <= >=
21syn keyword djangoStatement contained and as block endblock by cycle debug else elif
22syn keyword djangoStatement contained extends filter endfilter firstof for
23syn keyword djangoStatement contained endfor if endif ifchanged endifchanged
24syn keyword djangoStatement contained ifequal endifequal ifnotequal
25syn keyword djangoStatement contained endifnotequal in include load not now or
26syn keyword djangoStatement contained parsed regroup reversed spaceless
27syn keyword djangoStatement contained endspaceless ssi templatetag openblock
28syn keyword djangoStatement contained closeblock openvariable closevariable
29syn keyword djangoStatement contained openbrace closebrace opencomment
30syn keyword djangoStatement contained closecomment widthratio url with endwith
31syn keyword djangoStatement contained get_current_language trans noop blocktrans
32syn keyword djangoStatement contained endblocktrans get_available_languages
33syn keyword djangoStatement contained get_current_language_bidi plural
34
35" Django templete built-in filters
36syn keyword djangoFilter contained add addslashes capfirst center cut date
37syn keyword djangoFilter contained default default_if_none dictsort
38syn keyword djangoFilter contained dictsortreversed divisibleby escape escapejs
39syn keyword djangoFilter contained filesizeformat first fix_ampersands
40syn keyword djangoFilter contained floatformat get_digit join last length length_is
41syn keyword djangoFilter contained linebreaks linebreaksbr linenumbers ljust
42syn keyword djangoFilter contained lower make_list phone2numeric pluralize
43syn keyword djangoFilter contained pprint random removetags rjust slice slugify
44syn keyword djangoFilter contained safe safeseq stringformat striptags
45syn keyword djangoFilter contained time timesince timeuntil title truncatechars
46syn keyword djangoFilter contained truncatewords truncatewords_html unordered_list upper urlencode
47syn keyword djangoFilter contained urlize urlizetrunc wordcount wordwrap yesno
48
49" Keywords to highlight within comments
50syn keyword djangoTodo contained TODO FIXME XXX
51
52" Django template constants (always surrounded by double quotes)
53syn region djangoArgument contained start=/"/ skip=/\\"/ end=/"/
54
55" Mark illegal characters within tag and variables blocks
56syn match djangoTagError contained "#}\|{{\|[^%]}}\|[&#]"
57syn match djangoVarError contained "#}\|{%\|%}\|[<>!&#%]"
58
59" Django template tag and variable blocks
60syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display
61syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display
62
63" Django template 'comment' tag and comment block
64syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo
65syn region djangoComBlock start="{#" end="#}" contains=djangoTodo
66
67" Define the default highlighting.
68" Only when an item doesn't have highlighting yet
69
70hi def link djangoTagBlock PreProc
71hi def link djangoVarBlock PreProc
72hi def link djangoStatement Statement
73hi def link djangoFilter Identifier
74hi def link djangoArgument Constant
75hi def link djangoTagError Error
76hi def link djangoVarError Error
77hi def link djangoError Error
78hi def link djangoComment Comment
79hi def link djangoComBlock Comment
80hi def link djangoTodo Todo
81
82
83let b:current_syntax = "django"
84