robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
db210dd2a4
master
1" Vim syntax file 2" Language: TT2 (Perl Template Toolkit) 3" Maintainer: vim-perl <vim-perl@googlegroups.com> (need to be subscribed to post) 4" Author: Moriki, Atsushi <4woods+vim@gmail.com> 5" Homepage: https://github.com/vim-perl/vim-perl 6" Bugs/requests: https://github.com/vim-perl/vim-perl/issues 7" License: Vim License (see :help license) 8" Last Change: 2018 Mar 28 9" 10" Installation: 11" put tt2.vim and tt2html.vim in to your syntax directory. 12" 13" add below in your filetype.vim. 14" au BufNewFile,BufRead *.tt2 setf tt2 15" or 16" au BufNewFile,BufRead *.tt2 17" \ if ( getline(1) . getline(2) . getline(3) =~ '<\chtml' | 18" \ && getline(1) . getline(2) . getline(3) !~ '<[%?]' ) | 19" \ || getline(1) =~ '<!DOCTYPE HTML' | 20" \ setf tt2html | 21" \ else | 22" \ setf tt2 | 23" \ endif 24" 25" define START_TAG, END_TAG 26" "ASP" 27" :let b:tt2_syn_tags = '<% %>' 28" "PHP" 29" :let b:tt2_syn_tags = '<? ?>' 30" "TT2 and HTML" 31" :let b:tt2_syn_tags = '\[% %] <!-- -->' 32" 33" Changes: 34" 0.1.3 35" Changed fileformat from 'dos' to 'unix' 36" Deleted 'echo' that print obstructive message 37" 0.1.2 38" Added block comment syntax 39" e.g. [%# COMMENT 40" COMMENT TOO %] 41" [%# IT'S SAFE %] HERE IS OUTSIDE OF TT2 DIRECTIVE 42" [% # WRONG!! %] HERE STILL BE COMMENT 43" 0.1.1 44" Release 45" 0.1.0 46" Internal 47 48if ! exists ( "b:tt2_syn_tags" ) 49let b: tt2_syn_tags = '\[% %]' 50"let b:tt2_syn_tags = '\[% %] \[\* \*]' 51endif 52 53if ! exists ( "b:tt2_syn_inc_perl" ) 54let b: tt2_syn_inc_perl = 1 55endif 56 57if exists ( "b:current_syntax" ) 58finish 59endif 60 61let s: cpo_save = & cpo 62set cpo & vim 63 64syn case match 65 66syn cluster tt2_top_cluster contains = tt2_perlcode , tt2_tag_region 67 68" TT2 TAG Region 69if exists ( "b:tt2_syn_tags" ) 70 71let s: str = b: tt2_syn_tags . ' ' 72let s: str = substitute ( s: str , '^ \+' , '' , 'g' ) 73let s: str = substitute ( s: str , ' \+' , ' ' , 'g' ) 74 75while stridx ( s: str , ' ' ) > 0 76 77let s: st = strpart ( s: str , 0 , stridx ( s: str , ' ' )) 78let s: str = substitute ( s: str , '[^ ]* ' , '' , "" ) 79 80let s: ed = strpart ( s: str , 0 , stridx ( s: str , ' ' )) 81let s: str = substitute ( s: str , '[^ ]* ' , '' , "" ) 82 83exec 'syn region tt2_tag_region ' . 84 \'matchgroup=tt2_tag ' . 85 \'start=+\(' . s: st . '\)[-]\=+ ' . 86 \'end=+[-]\=\(' . s: ed . '\)+ ' . 87 \'contains=@tt2_statement_cluster keepend extend' 88 89exec 'syn region tt2_commentblock_region ' . 90 \'matchgroup=tt2_tag ' . 91 \'start=+\(' . s: st . '\)[-]\=\(#\)\@=+ ' . 92 \'end=+[-]\=\(' . s: ed . '\)+ ' . 93 \'keepend extend' 94 95"Include Perl syntax when 'PERL' 'RAWPERL' block 96if b: tt2_syn_inc_perl 97syn include @Perl syntax/perl.vim 98exec 'syn region tt2_perlcode ' . 99 \'start=+\(\(RAW\)\=PERL\s*[-]\=' . s: ed . '\(\n\)\=\)\@<=+ ' . 100 \'end=+' . s: st . '[-]\=\s*END+me=s-1 contains=@Perl keepend' 101endif 102 103"echo 'TAGS ' . s:st . ' ' . s:ed 104unlet s: st 105unlet s: ed 106endwhile 107 108else 109 110syn region tt2_tag_region 111 \matchgroup = tt2_tag 112 \start = +\(\[%\) [ - ] \= + 113 \end = +[ - ] \=%\] + 114 \contains = @tt2_statement_cluster keepend extend 115 116syn region tt2_commentblock_region 117 \matchgroup = tt2_tag 118 \start = +\(\[%\) [ - ] \=# + 119 \end = +[ - ] \=%\] + 120 \keepend extend 121 122"Include Perl syntax when 'PERL' 'RAWPERL' block 123if b: tt2_syn_inc_perl 124syn include @Perl syntax/perl.vim 125syn region tt2_perlcode 126 \start = +\(\(RAW\)\=PERL\s * [ - ] \=%]\(\n\)\=\)\@<= + 127 \end = +\[% [ - ] \=\s * END +me= s-1 128 \contains = @Perl keepend 129endif 130endif 131 132" Directive 133syn keyword tt2_directive contained 134 \GET CALL SET DEFAULT DEBUG 135 \LAST NEXT BREAK STOP BLOCK 136 \IF IN UNLESS ELSIF FOR FOREACH WHILE SWITCH CASE 137 \USE PLUGIN MACRO META 138 \TRY FINAL RETURN LAST 139 \CLEAR TO STEP AND OR NOT MOD DIV 140 \ELSE PERL RAWPERL END 141syn match tt2_directive +| +contained 142syn keyword tt2_directive contained nextgroup = tt2_string_q , tt2_string_qq , tt2_blockname skipwhite skipempty 143 \INSERT INCLUDE PROCESS WRAPPER FILTER 144 \THROW CATCH 145syn keyword tt2_directive contained nextgroup = tt2_def_tag skipwhite skipempty 146 \TAGS 147 148syn match tt2_def_tag "\S\+\s\+\S\+\|\<\w\+\> "contained 149 150syn match tt2_variable +\I\w * +contained 151syn match tt2_operator "[ +*/%:?- ] "contained 152syn match tt2_operator "\<\(mod\|div\|or\|and\|not\)\> "contained 153syn match tt2_operator "[ !=<> ] =\=\|&&\||| "contained 154syn match tt2_operator "\(\s\)\@<=_\(\s\)\@= "contained 155syn match tt2_operator "=>\|, "contained 156syn match tt2_deref "\( [ [:alnum: ] _)\]}]\s * \)\@<=\. "contained 157syn match tt2_comment +#. * $ +contained 158syn match tt2_func +\<\I\w * \(\s * (\)\@= +contained nextgroup = tt2_bracket_r skipempty skipwhite 159" 160syn region tt2_bracket_r start = +( +end = +) +contained contains = @tt2_statement_cluster keepend extend 161syn region tt2_bracket_b start = +\[ +end = +] +contained contains = @tt2_statement_cluster keepend extend 162syn region tt2_bracket_b start = +{ +end = +} +contained contains = @tt2_statement_cluster keepend extend 163 164syn region tt2_string_qq start = +" +end = +" + skip=+\\"+ contained contains =tt2_ivariable keepend extend 165syn region tt2_string_q start = +' +end = +' + skip=+\\'+ contained keepend extend 166 167syn match tt2_ivariable +\$\I\w * \>\(\.\I\w * \>\) * +contained 168syn match tt2_ivariable +\${\I\w * \>\(\.\I\w * \>\) * } +contained 169 170syn match tt2_number "\d\+ "contained 171syn match tt2_number "\d\+\.\d\+ "contained 172syn match tt2_number "0x\x\+ "contained 173syn match tt2_number "0\o\+ "contained 174 175syn match tt2_blockname "\f\+ "contained nextgroup = tt2_blockname_joint skipwhite skipempty 176syn match tt2_blockname "$\w\+ "contained contains = tt2_ivariable nextgroup = tt2_blockname_joint skipwhite skipempty 177syn region tt2_blockname start = +" +end = +" + skip=+\\"+ contained contains =tt2_ivariable nextgroup=tt2_blockname_joint keepend skipwhite skipempty 178syn region tt2_blockname start = +' +end = +' + skip=+\\'+ contained nextgroup =tt2_blockname_joint keepend skipwhite skipempty 179syn match tt2_blockname_joint "+ "contained nextgroup = tt2_blockname skipwhite skipempty 180 181syn cluster tt2_statement_cluster contains = tt2_directive , tt2_variable , tt2_operator , tt2_string_q , tt2_string_qq , tt2_deref , tt2_comment , tt2_func , tt2_bracket_b , tt2_bracket_r , tt2_number 182 183" Synchronizing 184syn sync minlines= 50 185 186hi def link tt2_tag Type 187hi def link tt2_tag_region Type 188hi def link tt2_commentblock_region Comment 189hi def link tt2_directive Statement 190hi def link tt2_variable Identifier 191hi def link tt2_ivariable Identifier 192hi def link tt2_operator Statement 193hi def link tt2_string_qq String 194hi def link tt2_string_q String 195hi def link tt2_blockname String 196hi def link tt2_comment Comment 197hi def link tt2_func Function 198hi def link tt2_number Number 199 200if exists ( "b:tt2_syn_tags" ) 201unlet b: tt2_syn_tags 202endif 203 204let b: current_syntax = "tt2" 205 206let & cpo = s: cpo_save 207unlet s: cpo_save 208 209" vim:ts=4:sw=4