mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-13 05:53:50 -05:00
Add jinja support, closes #269
This commit is contained in:
@@ -192,3 +192,97 @@ syn keyword htmlArg contained scriptlevel scriptminsize scriptsize scriptsizemul
|
||||
syn keyword htmlArg contained stretchy subscriptshift superscriptshift symmetric thickmathspace thinmathspace type valign verythickmathspace verythinmathspace
|
||||
syn keyword htmlArg contained veryverythickmathspace veryverythinmathspace voffset width xref
|
||||
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jinja') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim syntax file
|
||||
" Language: HTML (version 5)
|
||||
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
|
||||
" URL: http://rm.blog.br/vim/syntax/html.vim
|
||||
" Last Change: 2009 Aug 19
|
||||
" License: Public domain
|
||||
" (but let me know if you like :) )
|
||||
"
|
||||
" Note: This file just adds the new tags from HTML 5
|
||||
" and don't replace default html.vim syntax file
|
||||
"
|
||||
" Modified: othree <othree@gmail.com>
|
||||
" Changes: update to Draft 28 August 2010
|
||||
" add complete new attributes
|
||||
" add wai-aria attributes
|
||||
" add microdata attributes
|
||||
" add rdfa attributes
|
||||
|
||||
|
||||
syn keyword htmlTagName contained script
|
||||
" HTML 5 tags
|
||||
syn keyword htmlTagName contained article aside audio canvas command
|
||||
syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer
|
||||
syn keyword htmlTagName contained header hgroup keygen mark meter menu nav output
|
||||
syn keyword htmlTagName contained progress time ruby rt rp section source summary time track video wbr
|
||||
|
||||
" HTML 5 arguments
|
||||
" Core Attributes
|
||||
syn keyword htmlArg contained accesskey class contenteditable contextmenu dir
|
||||
syn keyword htmlArg contained draggable hidden id lang spellcheck style tabindex title
|
||||
" Event-handler Attributes
|
||||
syn keyword htmlArg contained onabort onblur oncanplay oncanplaythrough onchange
|
||||
syn keyword htmlArg contained onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover
|
||||
syn keyword htmlArg contained ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange
|
||||
syn keyword htmlArg contained onforminput oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata
|
||||
syn keyword htmlArg contained onloadedmetadata onloadstart onmousedown onmousemove onmouseout onmouseover onmouseup
|
||||
syn keyword htmlArg contained onmousewheel onpause onplay onplaying onprogress onratechange onreadystatechange
|
||||
syn keyword htmlArg contained onscroll onseeked onseeking onselect onshow onstalled onsubmit onsuspend ontimeupdate
|
||||
syn keyword htmlArg contained onvolumechange onwaiting
|
||||
" XML Attributes
|
||||
syn keyword htmlArg contained xml:lang xml:space xml:base
|
||||
" new features
|
||||
" <body>
|
||||
syn keyword htmlArg contained onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload
|
||||
syn keyword htmlArg contained onmessage onoffline ononline onpopstate onredo onresize onstorage onundo onunload
|
||||
" <video>, <audio>, <source>, <track>
|
||||
syn keyword htmlArg contained autoplay preload controls loop poster media kind charset srclang track
|
||||
" <form>, <input>, <button>
|
||||
syn keyword htmlArg contained form autocomplete autofocus list min max step
|
||||
syn keyword htmlArg contained formaction autofocus formenctype formmethod formtarget formnovalidate
|
||||
" <command>, <details>, <time>
|
||||
syn keyword htmlArg contained label icon open datetime pubdate
|
||||
|
||||
" Custom Data Attributes
|
||||
" http://dev.w3.org/html5/spec/Overview.html#custom-data-attribute
|
||||
syn match htmlArg "\<\(data(\-[a-z]\+)\+\)=" contained
|
||||
|
||||
" Microdata
|
||||
" http://dev.w3.org/html5/md/
|
||||
syn keyword htmlArg contained item itemid itemscope itemtype itemprop
|
||||
|
||||
" RDFa
|
||||
" http://www.w3.org/TR/rdfa-syntax/#a_xhtmlrdfa_dtd
|
||||
syn keyword htmlArg contained about typeof property resource content datatype rel rev
|
||||
|
||||
" WAI-ARIA States and Properties
|
||||
" http://www.w3.org/TR/wai-aria/states_and_properties
|
||||
syn keyword htmlArg contained role
|
||||
" Global States and Properties
|
||||
syn match htmlArg contained "\<aria-\(atomic\|busy\|controls\|describedby\)\>"
|
||||
syn match htmlArg contained "\<aria-\(disabled\|dropeffect\|flowto\|grabbed\)\>"
|
||||
syn match htmlArg contained "\<aria-\(haspopup\|hidden\|invalid\|label\)\>"
|
||||
syn match htmlArg contained "\<aria-\(labelledby\|live\|owns\|relevant\)\>"
|
||||
|
||||
" Widget Attributes
|
||||
syn match htmlArg contained "\<aria-\(autocomplete\|checked\|disabled\|expanded\)\>"
|
||||
syn match htmlArg contained "\<aria-\(haspopup\|hidden\|invalid\|label\)\>"
|
||||
syn match htmlArg contained "\<aria-\(level\|multiline\|multiselectable\|orientation\)\>"
|
||||
syn match htmlArg contained "\<aria-\(pressed\|readonly\|required\|selected\)\>"
|
||||
syn match htmlArg contained "\<aria-\(sort\|valuemax\|valuemin\|valuenow\|valuetext\|\)\>"
|
||||
|
||||
" Live Region Attributes
|
||||
syn match htmlArg contained "\<aria-\(atomic\|busy\|live\|relevant\|\)\>"
|
||||
|
||||
" Drag-and-Drop attributes
|
||||
syn match htmlArg contained "\<aria-\(dropeffect\|grabbed\)\>"
|
||||
|
||||
" Relationship Attributes
|
||||
syn match htmlArg contained "\<aria-\(activedescendant\|controls\|describedby\|flowto\|\)\>"
|
||||
syn match htmlArg contained "\<aria-\(labelledby\|owns\|posinset\|setsize\|\)\>"
|
||||
|
||||
90
syntax/jinja.vim
Normal file
90
syntax/jinja.vim
Normal file
@@ -0,0 +1,90 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jinja') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" jinja syntax file
|
||||
" Language: Jinja HTML template
|
||||
" Maintainer: Hsiaoming Yang <lepture@me.com>
|
||||
" Last Change: Sep 13, 2012
|
||||
|
||||
" only support 6.x+
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("main_syntax")
|
||||
let main_syntax = 'html'
|
||||
endif
|
||||
|
||||
runtime! syntax/html.vim
|
||||
unlet b:current_syntax
|
||||
|
||||
syntax case match
|
||||
|
||||
" jinja template built-in tags and parameters
|
||||
" 'comment' doesn't appear here because it gets special treatment
|
||||
syn keyword jinjaStatement contained if else elif endif is not
|
||||
syn keyword jinjaStatement contained for in recursive endfor
|
||||
syn keyword jinjaStatement contained raw endraw
|
||||
syn keyword jinjaStatement contained block endblock extends super scoped
|
||||
syn keyword jinjaStatement contained macro endmacro call endcall
|
||||
syn keyword jinjaStatement contained from import as do continue break
|
||||
syn keyword jinjaStatement contained filter endfilter set
|
||||
syn keyword jinjaStatement contained include ignore missing
|
||||
syn keyword jinjaStatement contained with without context endwith
|
||||
syn keyword jinjaStatement contained trans endtrans pluralize
|
||||
syn keyword jinjaStatement contained autoescape endautoescape
|
||||
|
||||
" jinja templete built-in filters
|
||||
syn keyword jinjaFilter contained abs attr batch capitalize center default
|
||||
syn keyword jinjaFilter contained dictsort escape filesizeformat first
|
||||
syn keyword jinjaFilter contained float forceescape format groupby indent
|
||||
syn keyword jinjaFilter contained int join last length list lower pprint
|
||||
syn keyword jinjaFilter contained random replace reverse round safe slice
|
||||
syn keyword jinjaFilter contained sort string striptags sum
|
||||
syn keyword jinjaFilter contained title trim truncate upper urlize
|
||||
syn keyword jinjaFilter contained wordcount wordwrap
|
||||
|
||||
" jinja template built-in tests
|
||||
syn keyword jinjaTest contained callable defined divisibleby escaped
|
||||
syn keyword jinjaTest contained even iterable lower mapping none number
|
||||
syn keyword jinjaTest contained odd sameas sequence string undefined upper
|
||||
|
||||
syn keyword jinjaFunction contained range lipsum dict cycler joiner
|
||||
|
||||
|
||||
" Keywords to highlight within comments
|
||||
syn keyword jinjaTodo contained TODO FIXME XXX
|
||||
|
||||
" jinja template constants (always surrounded by double quotes)
|
||||
syn region jinjaArgument contained start=/"/ skip=/\\"/ end=/"/
|
||||
syn region jinjaArgument contained start=/'/ skip=/\\'/ end=/'/
|
||||
syn keyword jinjaArgument contained true false
|
||||
|
||||
" Mark illegal characters within tag and variables blocks
|
||||
syn match jinjaTagError contained "#}\|{{\|[^%]}}\|[&#]"
|
||||
syn match jinjaVarError contained "#}\|{%\|%}\|[<>!&#%]"
|
||||
syn cluster jinjaBlocks add=jinjaTagBlock,jinjaVarBlock,jinjaComBlock,jinjaComment
|
||||
|
||||
" jinja template tag and variable blocks
|
||||
syn region jinjaTagBlock start="{%" end="%}" contains=jinjaStatement,jinjaFilter,jinjaArgument,jinjaFilter,jinjaTest,jinjaTagError display containedin=ALLBUT,@jinjaBlocks
|
||||
syn region jinjaVarBlock start="{{" end="}}" contains=jinjaFilter,jinjaArgument,jinjaVarError display containedin=ALLBUT,@jinjaBlocks
|
||||
syn region jinjaComBlock start="{#" end="#}" contains=jinjaTodo containedin=ALLBUT,@jinjaBlocks
|
||||
|
||||
|
||||
hi def link jinjaTagBlock PreProc
|
||||
hi def link jinjaVarBlock PreProc
|
||||
hi def link jinjaStatement Statement
|
||||
hi def link jinjaFunction Function
|
||||
hi def link jinjaTest Type
|
||||
hi def link jinjaFilter Identifier
|
||||
hi def link jinjaArgument Constant
|
||||
hi def link jinjaTagError Error
|
||||
hi def link jinjaVarError Error
|
||||
hi def link jinjaError Error
|
||||
hi def link jinjaComment Comment
|
||||
hi def link jinjaComBlock Comment
|
||||
hi def link jinjaTodo Todo
|
||||
|
||||
let b:current_syntax = "jinja"
|
||||
Reference in New Issue
Block a user