Skip to content

Commit

Permalink
Accommodate old Vim (<7.4) versions using perl6.vim
Browse files Browse the repository at this point in the history
Running "make install" will now remove the regex optimization from the
syntax file if the user has an old Vim.

For those who try to run an unmodified perl6.vim, we now print an error
when the syntax file is loaded.
  • Loading branch information
hinrik committed Mar 1, 2015
1 parent 987659f commit 587a278
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -10,7 +10,7 @@ default: preproc
dirs:
mkdir -p $(FTPLUGIN) $(INDENT) $(SYNTAX) $(TOOLS)

install: dirs
install: dirs fix_old_vim
cp ftplugin/*.vim $(FTPLUGIN)/
cp indent/*.vim $(INDENT)/
cp syntax/*.vim $(SYNTAX)/
Expand Down Expand Up @@ -63,3 +63,7 @@ try-tiny: contrib_syntax

preproc:
tools/preproc.pl syntax/perl6.vim.pre > syntax/perl6.vim

# this gets rid of a regex optimization introduced in Vim 7.4
fix_old_vim:
expr `vim --version|head -n1|grep -Poh '\d\.\d'|head -n1` \< 7.4 >/dev/null && sed -i 's/\\@[0-9]\+/\\@/g; /version < 740/d' syntax/perl6.vim; true
2 changes: 2 additions & 0 deletions syntax/perl6.vim
Expand Up @@ -33,6 +33,8 @@
" To enable folding:
" let perl6_fold=1

if version < 740 | throw "perl6.vim uses regex syntax which Vim <7.4 doesn't support. Try 'make fix_old_vim' in the vim-perl repository." | endif

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
Expand Down
2 changes: 2 additions & 0 deletions syntax/perl6.vim.pre
Expand Up @@ -33,6 +33,8 @@
" To enable folding:
" let perl6_fold=1

if version < 740 | throw "perl6.vim uses regex syntax which Vim <7.4 doesn't support. Try 'make fix_old_vim' in the vim-perl repository." | endif

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
Expand Down

0 comments on commit 587a278

Please sign in to comment.