diff --git a/t/01_highlighting.t b/t/01_highlighting.t index 64c6ccd3..52d70448 100644 --- a/t/01_highlighting.t +++ b/t/01_highlighting.t @@ -7,17 +7,7 @@ use File::Find; use File::Spec::Functions qw; use Test::More; use Test::Differences; -use Text::VimColor 0.24; - -# hack to work around a silly limitation in Text::VimColor, -# will remove it when Text::VimColor has been patched -%Text::VimColor::SYNTAX_TYPE = map { $_ => 1 } qw( - Comment Constant Identifier Statement PreProc Type Special Underlined - Ignore Error Todo String Character Number Boolean Float Function - Conditional Repeat Label Operator Keyword Exception Include Define Macro - PreCondit StorageClass Structure Typedef Tag SpecialChar Delimiter - SpecialComment Debug -); +use Text::VimColor 0.25; my %LANG_HIGHLIGHTERS = ( perl => [ @@ -40,23 +30,21 @@ my %LANG_HIGHLIGHTERS = ( sub construct_highlighter { my ( $lang, $option_set ) = @_; - my $color_file = catfile('t', 'define_all.vim'); - my $css_file = catfile('t', 'vim_syntax.css'); - my $syntax_file = catfile('syntax', "$lang.vim"); my $ftplugin_file = catfile('ftplugin', "$lang.vim"); - my $css_url = join('/', '..', '..', 't', 'vim_syntax.css'); + my $css_file = catfile('t', 'vim_syntax.css'); + my $css_url = join('/', '..', '..', 't', 'vim_syntax.css'); return Text::VimColor->new( html_full_page => 1, html_inline_stylesheet => 0, html_stylesheet_url => $css_url, + all_syntax_groups => 1, extra_vim_options => [ @$option_set, '+set runtimepath=.', "+source $ftplugin_file", "+source $syntax_file", - "+source $color_file", # all syntax classes should be defined "+syn sync fromstart", ], ); diff --git a/t/02_syntax_tt2.t b/t/02_syntax_tt2.t index 46868070..308f82e1 100644 --- a/t/02_syntax_tt2.t +++ b/t/02_syntax_tt2.t @@ -5,32 +5,20 @@ use warnings; use File::Spec::Functions qw; use Test::More tests => 3; # can we upgrade to 0.88 and use done_testing? use Test::Differences; -use Text::VimColor; - -# hack to work around a silly limitation in Text::VimColor, -# will remove it when Text::VimColor has been patched -{ - package TrueHash; - use base 'Tie::StdHash'; - sub EXISTS { return 1 }; -} -tie %Text::VimColor::SYNTAX_TYPE, 'TrueHash'; +use Text::VimColor 0.25; my $lang = 'tt2'; -my $syntax_file = catfile('syntax', "$lang.vim"); -my $color_file = catfile('t', 'define_all.vim'); +my $syntax_file = catfile('syntax', "$lang.vim"); sub parse_string { my ($string, $scripts) = @_; my $syntax = Text::VimColor->new( string => $string, - vim_options => [ - qw(-RXZ -i NONE -u NONE -U NONE -N -n), # for performance - '+set nomodeline', # for performance + extra_vim_options => [ '+set runtimepath=.', # don't consider system runtime files @{ $scripts || [] }, "+source $syntax_file", - "+source $color_file", # all syntax classes should be defined + '+syn sync fromstart', ], ); return $syntax->marked; @@ -72,12 +60,10 @@ TT2 [ Type => '[% ' ], [ Statement => 'PERL' ], [ Type => ' %]' ], - [ '' => "\n" ], - [ 'tt2_perlcode' => ' ' ], + [ '' => "\n " ], [ Identifier => 'print(' ], [ String => '"vim"' ], - [ 'tt2_perlcode' => ');' ], - [ '' => "\n" ], + [ '' => ");\n" ], [ Type => '[% ' ], [ Statement => 'END' ], [ Type => ' %]' ], diff --git a/t/05_syntax_mason.t b/t/05_syntax_mason.t index 49e04329..9d9d75f5 100644 --- a/t/05_syntax_mason.t +++ b/t/05_syntax_mason.t @@ -5,32 +5,20 @@ use warnings; use File::Spec::Functions qw; use Test::More tests => 6; # can we upgrade to 0.88 and use done_testing? use Test::Differences; -use Text::VimColor; - -# hack to work around a silly limitation in Text::VimColor, -# will remove it when Text::VimColor has been patched -{ - package TrueHash; - use base 'Tie::StdHash'; - sub EXISTS { return 1 }; -} -tie %Text::VimColor::SYNTAX_TYPE, 'TrueHash'; +use Text::VimColor 0.25; my $lang = 'mason'; -my $syntax_file = catfile('syntax', "$lang.vim"); -my $color_file = catfile('t', 'define_all.vim'); +my $syntax_file = catfile('syntax', "$lang.vim"); sub parse_string { my ($string, $scripts) = @_; my $syntax = Text::VimColor->new( string => $string, - vim_options => [ - qw(-RXZ -i NONE -u NONE -U NONE -N -n), # for performance - '+set nomodeline', # for performance + extra_vim_options => [ '+set runtimepath=.', # don't consider system runtime files @{ $scripts || [] }, "+source $syntax_file", - "+source $color_file", # all syntax classes should be defined + '+syn sync fromstart', ], ); return $syntax->marked; @@ -43,14 +31,14 @@ eq_or_diff MASON [ [ Delimiter => '<%method title>' ], - [ masonMethod => 'Home' ], + [ '' => 'Home' ], [ Delimiter => '' ], [ '' => "\n

" ], [ Delimiter => '<%perl>' ], [ Statement => "print" ], - [ masonPerl => ' ' ], + [ '' => ' ' ], [ String => '"foobar"' ], - [ masonPerl => ';' ], + [ '' => ';' ], [ Delimiter => "" ], [ '' => "

\n" ], ], @@ -77,10 +65,9 @@ MASON [ Statement => '=cut' ], [ '' => "\n" ], [ Statement => 'print' ], - [ masonInit => ' ' ], + [ '' => ' ' ], [ String => '"foo"' ], - [ masonInit => ';' ], - [ '' => "\n" ], + [ '' => ";\n" ], [ Delimiter => '' ], [ '' => "\n" ], ], @@ -95,17 +82,15 @@ eq_or_diff MASON [ [ Delimiter => '%'], - [ masonLine => ' '], + [ '' => ' '], [ Conditional => 'if'], - [ masonLine => ' ('], + [ '' => ' ('], [ Identifier => '$boolean'], - [ masonLine => ') {'], - [ '' => "\n
  • hello
  • \n"], + [ '' => ") {\n
  • hello
  • \n"], [ Delimiter => "%"], - [ masonLine => ' }'], - [ '' => "\n"], + [ '' => " }\n"], [ Delimiter => "<& SELF:header"], - [ masonComp => ' '], + [ '' => ' '], [ Delimiter => "&>"], [ '' => "\n"], ], @@ -121,20 +106,16 @@ asdf MASON [ [ Delimiter => '<&| foo'], - [ masonComp => ', '], + [ '' => ', '], [ String => 'bar'], - [ masonComp => ' => '], + [ '' => ' => '], [ Identifier => '$baz'], - [ masonComp => ' '], + [ '' => ' '], [ Delimiter => '&>'], - [ '' => "\n"], - [ masonCompContent => "asdf"], - [ '' => "\n"], + [ '' => "\nasdf\n"], [ Delimiter => "%"], [ Comment => '# foo'], - [ '' => "\n"], - [ masonCompContent => ""], - [ '' => "\n"], + [ '' => "\n\n"], [ Delimiter => ""], [ '' => "\n"], ], @@ -147,33 +128,32 @@ eq_or_diff % map { $_ => 'y' } qw(qa sa ); MASON [ - ['Delimiter','%'], - ['masonLine',' '], - ['Repeat','for'], - ['masonLine',' '], - ['Statement','my'], - ['masonLine',' '], - ['Identifier','$t'], - ['masonLine',' ('], - ['String','qw{foo bar}'], - ['masonLine',') { '], - ['Comment','# foo'], - ['',"\n
    \n"], - ['Delimiter','%'], - ['masonLine',' '], - ['Statement','map'], - ['masonLine',' '], - ['Statement','{'], - ['masonLine',' '], - ['Identifier','$_'], - ['masonLine',' => '], - ['String','\'y\''], - ['masonLine',' '], - ['Statement','}'], - ['masonLine',' '], - ['String','qw(qa sa )'], - ['masonLine',';'], - ['',"\n"], + [Delimiter =>'%'], + ['' => ' '], + [Repeat => 'for'], + ['' =>' '], + [Statement => 'my'], + ['' => ' '], + [Identifier => '$t'], + ['' => ' ('], + [String => 'qw{foo bar}'], + ['' => ') { '], + [Comment => '# foo'], + ['' => "\n
    \n"], + [Delimiter => '%'], + ['' => ' '], + [Statement => 'map'], + ['' => ' '], + [Statement => '{'], + ['' => ' '], + [Identifier => '$_'], + ['' => ' => '], + [String => '\'y\''], + ['' => ' '], + [Statement => '}'], + ['' => ' '], + [String => 'qw(qa sa )'], + ['' => ";\n"], ], 'basic Template syntax'; @@ -191,30 +171,27 @@ dsfsdf+2 %> MASON [ - ['Delimiter','<%'], - ['masonExpr',' '], - ['Comment','# This is a single-line comment'], - ['',"\n"], - ['masonExpr','foo+'], - ['Number',2], - ['',"\n"], - ['Delimiter','%>'], - ['',"\ndsfsdf+2\n\n"], - ['Delimiter','<%'], - ['masonExpr',' '], - ['Comment','# foo '], - ['Delimiter','%>'], - ['',"\n"], - ['Delimiter','<%'], - ['',"\n"], - ['masonExpr',' '], - ['Comment','# This is a'], - ['',"\n"], - ['masonExpr',' '], - ['Comment','# multi-line comment'], - ['',"\n"], - ['Delimiter','%>'], - ['',"\n"], + [Delimiter => '<%'], + ['' => ' '], + [Comment => '# This is a single-line comment'], + ['' => "\nfoo+"], + [Number => 2], + ['' => "\n"], + [Delimiter => '%>'], + ['' => "\ndsfsdf+2\n\n"], + [Delimiter => '<%'], + ['' => ' '], + [Comment => '# foo '], + [Delimiter => '%>'], + ['' => "\n"], + [Delimiter => '<%'], + ['' => "\n "], + [Comment => '# This is a'], + ['' => "\n "], + [Comment => '# multi-line comment'], + ['' => "\n"], + [Delimiter => '%>'], + ['' => "\n"], ], 'basic Template syntax'; diff --git a/t/define_all.vim b/t/define_all.vim deleted file mode 100644 index e6cdc1a6..00000000 --- a/t/define_all.vim +++ /dev/null @@ -1,53 +0,0 @@ -" Vim color file -" Filename: define_all -" Maintainer: vim-perl -" Installation: Drop this file in your $VIMRUNTIME/colors/ directory -" -" This is a dummy color file that defines a color for every syntax class. - -if version > 580 - " no guarantees for version 5.8 and below, - " but this makes it stop complaining - hi clear - if exists("syntax_on") - syntax reset - endif -endif - -let g:colors_name = "define_all" - -hi Normal ctermfg=7 -hi Comment ctermfg=7 -hi Constant ctermfg=7 -hi Special ctermfg=7 -hi Identifier ctermfg=7 -hi Statement ctermfg=7 -hi PreProc ctermfg=7 -hi Type ctermfg=7 -hi Underlined ctermfg=7 -hi Ignore ctermfg=7 -hi Error ctermfg=7 -hi Todo ctermfg=7 -hi String ctermfg=7 -hi Character ctermfg=7 -hi Number ctermfg=7 -hi Boolean ctermfg=7 -hi Float ctermfg=7 -hi Function ctermfg=7 -hi Conditional ctermfg=7 -hi Repeat ctermfg=7 -hi Label ctermfg=7 -hi Operator ctermfg=7 -hi Keyword ctermfg=7 -hi Exception ctermfg=7 -hi Include ctermfg=7 -hi Define ctermfg=7 -hi Macro ctermfg=7 -hi PreCondit ctermfg=7 -hi StorageClass ctermfg=7 -hi Typedef ctermfg=7 -hi Tag ctermfg=7 -hi SpecialChar ctermfg=7 -hi Delimiter ctermfg=7 -hi SpecialComment ctermfg=7 -hi Debug ctermfg=7 diff --git a/tools/Local/VimColor.pm b/tools/Local/VimColor.pm index cd2327cc..a7225bcb 100644 --- a/tools/Local/VimColor.pm +++ b/tools/Local/VimColor.pm @@ -6,13 +6,6 @@ use warnings; use File::Spec; use Text::VimColor; -{ - package TrueHash; - use base 'Tie::StdHash'; - sub EXISTS { return 1 }; -} -tie %Text::VimColor::SYNTAX_TYPE, 'TrueHash'; - sub new { my ( $class, %params ) = @_; @@ -22,20 +15,17 @@ sub new { my $ftplugin_file = File::Spec->catfile('ftplugin', "$lang.vim"); # XXX ??? my $css_url = join('/', '..', '..', 't', 'vim_syntax.css'); - my $color_file = File::Spec->catfile('t', 'define_all.vim'); my $hilite = Text::VimColor->new( html_full_page => 1, html_inline_stylesheet => 0, html_stylesheet_url => $css_url, - vim_options => [ - qw(-RXZ -i NONE -u NONE -U NONE -N -n), # for performance - '+set nomodeline', # for performance + extra_vim_options => [ '+set runtimepath=.', # don't consider system runtime files '+let perl_include_pod=1', "+source $ftplugin_file", "+source $syntax_file", - "+source $color_file", # all syntax classes should be defined + '+syn sync fromstart', ], );