summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2016-01-28 18:14:32 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2016-01-28 18:14:32 +0100
commitb0823d20685d0c03e70de3abfc85d79a8188d292 (patch)
tree3bda08e95f18383a7b1b34d92a4732335ac04647
parentb4a6290b42701b09069e052d1c3c1aa904752254 (diff)
downloadvim-polyglot-b0823d20685d0c03e70de3abfc85d79a8188d292.tar.gz
vim-polyglot-b0823d20685d0c03e70de3abfc85d79a8188d292.zip
Change twig provider, close #102v2.7.2
-rw-r--r--README.md2
-rwxr-xr-xbuild2
-rw-r--r--ftdetect/polyglot.vim5
-rw-r--r--ftplugin/twig.vim9
-rw-r--r--syntax/twig.vim36
5 files changed, 29 insertions, 25 deletions
diff --git a/README.md b/README.md
index 026a1bea..2ea962a3 100644
--- a/README.md
+++ b/README.md
@@ -96,7 +96,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [tmux](https://github.com/tejr/vim-tmux) (syntax, ftdetect)
- [tomdoc](https://github.com/wellbredgrapefruit/tomdoc.vim) (syntax)
- [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin, ftdetect)
-- [twig](https://github.com/beyondwords/vim-twig) (syntax, ftplugin, ftdetect)
+- [twig](https://github.com/evidens/vim-twig) (syntax, ftplugin)
- [typescript](https://github.com/leafgarland/typescript-vim) (syntax, indent, compiler, ftplugin, ftdetect)
- [vala](https://github.com/tkztmk/vim-vala) (syntax, indent, ftdetect)
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)
diff --git a/build b/build
index c500b82e..d6a87035 100755
--- a/build
+++ b/build
@@ -167,7 +167,7 @@ PACKS="
tmux:tejr/vim-tmux
tomdoc:wellbredgrapefruit/tomdoc.vim
toml:cespare/vim-toml
- twig:beyondwords/vim-twig
+ twig:evidens/vim-twig
typescript:leafgarland/typescript-vim
vala:tkztmk/vim-vala
vbnet:vim-scripts/vbnet.vim
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 52b1768d..dfc9c981 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -450,11 +450,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1
autocmd BufNewFile,BufRead *.toml set filetype=toml
autocmd BufNewFile,BufRead Cargo.lock set filetype=toml
endif
-if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
-
-autocmd BufNewFile,BufRead *.twig set filetype=twig
-autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
-endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
autocmd BufNewFile,BufRead *.ts,*.tsx setlocal filetype=typescript
diff --git a/ftplugin/twig.vim b/ftplugin/twig.vim
index b4735485..8fa94a41 100644
--- a/ftplugin/twig.vim
+++ b/ftplugin/twig.vim
@@ -8,14 +8,15 @@ 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<"
+if exists("b:did_ftplugin")
+ let b:undo_ftplugin .= "|setlocal comments< formatoptions<"
+else
+ let b:undo_ftplugin = "setlocal comments< formatoptions<"
+endif
" vim:set sw=2:
diff --git a/syntax/twig.vim b/syntax/twig.vim
index 1e4bc8fd..5fe20d7d 100644
--- a/syntax/twig.vim
+++ b/syntax/twig.vim
@@ -1,13 +1,14 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
" Vim syntax file
-" Language: Twig template
-" Maintainer: Gabriel Gosselin <gabrielNOSPAM@evidens.ca>
-" Last Change: 2011 July 27
-" Version: 1.0
+" Language: Twig template
+" Maintainer: Gabriel Gosselin <gabrielNOSPAM@evidens.ca>
+" Last Change: 2014 December 15
+" Version: 1.1
"
" Based Jinja syntax by: Armin Ronacher <armin.ronacher@active-4.com>
-"
+" With modifications by Benji Fisher, Ph.D.
+"
" Known Bugs:
" because of odd limitations dicts and the modulo operator
" appear wrong in the template.
@@ -16,11 +17,21 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
"
" 2008 May 9: Added support for Jinja2 changes (new keyword rules)
" 2011 July 27: Changed all references of jinja tp twig
+" 2014 December 4: Do not assume that the base filetype is HTML.
+
+if exists('b:main_syntax')
+ finish
+endif
+if exists('b:current_syntax')
+ let b:main_syntax = b:current_syntax
+else
+ let b:main_syntax = 'twig'
+endif
syntax case match
-" Jinja template built-in tags and parameters (without filter, macro, is and raw, they
-" have special threatment)
+" Twig template built-in tags and parameters (without filter, macro, is and
+" raw, they have special treatment)
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
@@ -37,7 +48,7 @@ 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_]*/
-" Jinja template constants
+" 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]\+\)\?/
@@ -48,7 +59,7 @@ syn match twigPunctuation containedin=twigVarBlock,twigTagBlock,twigNested conta
syn match twigOperator containedin=twigVarBlock,twigTagBlock,twigNested contained /\./ nextgroup=twigAttribute
syn match twigAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/
-" Jinja template tag and variable blocks
+" 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
@@ -56,10 +67,10 @@ syn region twigTagBlock matchgroup=twigTagDelim start=/{%-\?/ end=/-\?%}/ skipwh
syn region twigVarBlock matchgroup=twigVarDelim start=/{{-\?/ end=/-\?}}/ containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment
-" Jinja template 'raw' tag
+" Twig template 'raw' tag
syn region twigRaw matchgroup=twigRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,twigTagBlock,twigVarBlock,twigString,twigComment
-" Jinja comments
+" 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
@@ -107,7 +118,4 @@ if version >= 508 || !exists("did_twig_syn_inits")
delcommand HiLink
endif
-let b:current_syntax = "twig"
-
-
endif