Reputation: 43437
I am dealing with a lot of files which have qq{...}
strings that do a great job at tripping up vim
making it turn the entire rest of the file green.
I have tried this perl syntax definition to no avail, and I also noticed that it is dated older than the perl.vim
syntax-file that my vim came with.
I am using vim 7.3.918, freshly compiled from mercurial source, and its perl syntax file looks like this:
1 " Vim syntax file
2 " Language: Perl 5
3 " Maintainer: Andy Lester <[email protected]>
4 " URL: http://github.com/petdance/vim-perl/tree/master
5 " Last Change: 2010-08-10
6 " Contributors: Andy Lester <[email protected]>
7 " Hinrik Örn Sigurðsson <[email protected]>
8 " Lukas Mai <l.mai.web.de>
9 " Nick Hibma <[email protected]>
10 " Sonia Heimann <[email protected]>
11 " and many others.
12 "
13 " Please download most recent version first before mailing
14 " any comments.
15 "
16 " The following parameters are available for tuning the
17 " perl syntax highlighting, with defaults given:
18 " 19 " unlet perl_include_pod
20 " unlet perl_no_scope_in_variables
21 " unlet perl_no_extended_vars
22 " unlet perl_string_as_statement
23 " unlet perl_no_sync_on_sub
24 " unlet perl_no_sync_on_global_var
25 " let perl_sync_dist = 100
26 " unlet perl_fold
27 " unlet perl_fold_blocks
28 " let perl_nofold_packages = 1
29 " let perl_nofold_subs = 1
...
It dies on qq{}
code. They usually can be addressed by using other delimiters, but it's a lot of code I'm talking about here.
I tried looking at the part of this perl.vim
that deals with the q/qq/qr/qx quoting, but it is spectacularly complex.
Here's an example of some code that trips it up good:
I cannot paste any more code, so you'll have to trust me that basically all content in the rest of the file becomes treated as a string.
It certainly looks like the problem is that the }
at the end of $layout->{ID}
gets interpreted as the end of the qq{}
.
But that can't be the case because this code runs. It does not crash and burn. Therefore vim is wrong and must be more intelligent when matching up the }
. However, as this one line shows, the bracket can be at the end of the line...
At this point I'm not even sure if it is possible at all to know where the qq{}
ends without some sort of parsing that the syntax definition isn't able to perform.
Upvotes: 2
Views: 434
Reputation: 43437
this is a vim plugin that significantly improved my vim 7.3's ability to highlight perl.
Hopefully this all will make its way into core vim 7.4
Upvotes: 2
Reputation: 98398
Add a #'
at the end of the problem lines? Sorry I don't have anything better to suggest.
This is an area where perl allows more flexibility than syntax highlighters can realistically support.
Upvotes: 1