forked from evidens/vim-twig
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 324d6b8
Showing
6 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# vim-twig | ||
|
||
## About | ||
Supports Twig PHP templates [http://www.twig-project.org/][1] | ||
|
||
Original syntax highlighting by [Alex Suraci][2] | ||
|
||
----- | ||
## Installation | ||
|
||
This scripts bundles is compatible with [vim-addon-manager][3] | ||
|
||
|
||
|
||
[1]: http://www.twig-project.org/ | ||
[2]: http://darcsden.com/daniel/dotfiles/browse/.vim/syntax/twig.vim | ||
[3]: https://github.com/MarcWeber/vim-addon-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
" Twig | ||
autocmd BufNewFile,BufRead *.twig set filetype=twig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
" Vim filetype plugin | ||
" Language: Twig | ||
" Maintainer: F. Gabriel Gosselin <gabrielNOSPAM@evidens.ca> | ||
|
||
if exists("b:did_ftplugin") | ||
finish | ||
endif | ||
|
||
runtime! ftplugin/html.vim ftplugin/html*.vim ftplugin/html/*.vim | ||
unlet! b:did_ftplugin | ||
|
||
setlocal comments=s:{#,ex:#} | ||
setlocal formatoptions+=tcqln | ||
" setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+ | ||
|
||
let b:undo_ftplugin .= "|setl cms< com< fo<" | ||
|
||
" vim:set sw=2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Basic Twig snippets | ||
# Maintainer: F. Gabriel Gosselin <gabrielNOSPAM@evidens.ca> | ||
|
||
# if | ||
snippet if | ||
{% if ${1} %} | ||
${2} | ||
{% endif %} | ||
# for | ||
snippet for | ||
{% for ${2:} in ${1} %} | ||
${3}{{ $2 }} | ||
{% endfor %} | ||
# include | ||
snippet inc | ||
{% include "${1}" %} | ||
# extend | ||
snippet ext | ||
{% extends "${1}" %} | ||
# Single Regular execution block | ||
snippet %% | ||
{% ${1} %} | ||
# Open/close block | ||
snippet %end | ||
{% ${1:block} %}${2}{% end$1 %} | ||
# Named block | ||
snippet block | ||
{% block ${1:name} %}${2}{% endblock %} | ||
snippet f_date | ||
{{ ${1:a_date}|date("${2:m/d/Y}") }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
" Vim syntax file | ||
" Language: Twig template | ||
" Maintainer: Alex Suraci <i.am@toogeneric.com> | ||
" Last Change: 2008 Sep 28 | ||
" Version: 1.0 | ||
|
||
if version < 600 | ||
syntax clear | ||
elseif exists("b:current_syntax") | ||
finish | ||
endif | ||
|
||
syntax case match | ||
|
||
" Twig template built-in tags and parameters (without filter, macro, is and raw, they | ||
" have special threatment) | ||
syn keyword twigStatement containedin=twigVarBlock,twigTagBlock,twigNested contained and if else in not or recursive as import | ||
|
||
syn keyword twigStatement containedin=twigVarBlock,twigTagBlock,twigNested contained is filter skipwhite nextgroup=twigFilter | ||
syn keyword twigStatement containedin=twigTagBlock contained macro skipwhite nextgroup=twigFunction | ||
syn keyword twigStatement containedin=twigTagBlock contained block skipwhite nextgroup=twigBlockName | ||
|
||
" Variable Names | ||
syn match twigVariable containedin=twigVarBlock,twigTagBlock,twigNested contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ | ||
syn keyword twigSpecial containedin=twigVarBlock,twigTagBlock,twigNested contained false true none loop super caller varargs kwargs | ||
|
||
" Filters | ||
syn match twigOperator "|" containedin=twigVarBlock,twigTagBlock,twigNested contained nextgroup=twigFilter | ||
syn match twigFilter contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ | ||
syn match twigFunction contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ | ||
syn match twigBlockName contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/ | ||
|
||
" Twig template constants | ||
syn region twigString containedin=twigVarBlock,twigTagBlock,twigNested contained start=/"/ skip=/\\"/ end=/"/ | ||
syn region twigString containedin=twigVarBlock,twigTagBlock,twigNested contained start=/'/ skip=/\\'/ end=/'/ | ||
syn match twigNumber containedin=twigVarBlock,twigTagBlock,twigNested contained /[0-9]\+\(\.[0-9]\+\)\?/ | ||
|
||
" Operators | ||
"syn match twigOperator containedin=twigVarBlock,twigTagBlock,twigNested contained /[+\-*\/<>=!,:]/ | ||
syn match twigPunctuation containedin=twigVarBlock,twigTagBlock,twigNested contained /[()\[\]]/ | ||
syn match twigOperator containedin=twigVarBlock,twigTagBlock,twigNested contained /\./ nextgroup=twigAttribute | ||
syn match twigVar /\$/ nextgroup=twigAttribute containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment | ||
syn match twigAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/ nextgroup=twigOperator | ||
|
||
" Twig template tag and variable blocks | ||
syn region twigNested matchgroup=twigOperator start="(" end=")" transparent display containedin=twigVarBlock,twigTagBlock,twigNested contained | ||
syn region twigNested matchgroup=twigOperator start="\[" end="\]" transparent display containedin=twigVarBlock,twigTagBlock,twigNested contained | ||
"syn region twigNested matchgroup=twigOperator start="{" end="}" transparent display containedin=twigVarBlock,twigTagBlock,twigNested contained | ||
syn region twigTagBlock matchgroup=twigTagDelim start=/{%-\?/ end=/-\?%}/ skipwhite containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment | ||
|
||
syn region twigVarBlock matchgroup=twigVarDelim start=/\${/ end=/}/ containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment | ||
"syn region twigVarBlock matchgroup=twigVarDelim start=/$[a-zA-Z_]/ end=/[^a-zA-Z0-9.]/ containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment | ||
|
||
|
||
" Twig template 'raw' tag | ||
"syn region twigRaw matchgroup=twigRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,twigTagBlock,twigVarBlock,twigString,twigComment | ||
|
||
" Twig comments | ||
syn region twigComment matchgroup=twigCommentDelim start="{#" end="#}" containedin=ALLBUT,twigTagBlock,twigVarBlock,twigString | ||
|
||
" Block start keywords. A bit tricker. We only highlight at the start of a | ||
" tag block and only if the name is not followed by a comma or equals sign | ||
" which usually means that we have to deal with an assignment. | ||
syn match twigStatement containedin=twigTagBlock contained skipwhite /\({%-\?\s*\)\@<=\<[a-zA-Z_][a-zA-Z0-9_]*\>\(\s*[,=]\)\@!/ | ||
|
||
" and context modifiers | ||
"syn match twigStatement containedin=twigTagBlock contained /\<with\(out\)\?\s\+context\>/ skipwhite | ||
|
||
|
||
" 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_twig_syn_inits") | ||
if version < 508 | ||
let did_twig_syn_inits = 1 | ||
command -nargs=+ HiLink hi link <args> | ||
else | ||
command -nargs=+ HiLink hi def link <args> | ||
endif | ||
|
||
HiLink twigPunctuation twigOperator | ||
HiLink twigAttribute twigVariable | ||
HiLink twigFunction twigFilter | ||
|
||
HiLink twigTagDelim twigTagBlock | ||
HiLink twigVarDelim twigVarBlock | ||
HiLink twigCommentDelim twigComment | ||
HiLink twigRawDelim twig | ||
|
||
HiLink twigSpecial Special | ||
HiLink twigOperator Normal | ||
"HiLink twigRaw Normal | ||
HiLink twigTagBlock PreProc | ||
HiLink twigVarBlock PreProc | ||
HiLink twigStatement Statement | ||
HiLink twigFilter Function | ||
HiLink twigBlockName Function | ||
HiLink twigVariable Identifier | ||
HiLink twigVar Identifier | ||
HiLink twigString Constant | ||
HiLink twigNumber Constant | ||
HiLink twigComment Comment | ||
|
||
delcommand HiLink | ||
endif | ||
|
||
let b:current_syntax = "twig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name" : "vim-twig", | ||
"version" : "0.1", | ||
"author" : "F. Gabriel Gosselin <gabriel@evidens.ca>", | ||
"maintainer" : "F. Gabriel Gosselin <gabriel@evidens.ca>", | ||
"repository: { "type" : "git", "url" : "git://github.com/beyondwords/vim-twig.git"}, | ||
"dependencies" : {}, | ||
"description" : "Support Twig template language" | ||
} |