vim syntax highlighting for embedded pod in XS
- From: muppet <scott asofyet org>
- To: gtk-perl list <gtk-perl-list gnome org>
- Subject: vim syntax highlighting for embedded pod in XS
- Date: Sat, 16 Aug 2003 16:55:58 -0400
the XS "language" allows you to embed POD directly in the XS file, at
any point. xsubpp strips the POD from the first directive found in an
open area up to a =cut, and replaces all such stripped sections with a
C comment that says "/* stripped embedded pod */".
because of that replacement, you can't put the pod in a C comment, and
thus you have a bunch of bare text in your XS file that messes with
vim's syntax highlighting.
for those of you who like to hack XS and use vim 6 to do it, i have
found something that fixes it:
i created a new file, .vim/after/syntax/xs.vim ... this file will be
run by vim after all the normal syntax highlighting stuff, and thus is
to be used for overrides and additions. into that, i copied a relevant
section from the perl.vim syntax file
/usr/share/vim/vim61/syntax/perl.xs. i'm no vim syntax wizard, so i
wasn't sure how to make the syn include line look for pod.vim in the
path correctly (the code that's there appears to look for one in the
same directory as the file currently being executed), so i hardcoded
the path. naturally, you'll have to find the right path for your
system (or do it correctly :-).
~/.vim/after/syntax/xs.vim:
-=-=-=-=-=-=-
" POD starts with ^=<word> and ends with ^=cut
if exists("perl_include_pod")
" Include a while extra syntax file
" syn include @Pod <sfile>:p:h/pod.vim
syn include @Pod /usr/share/vim/vim61/syntax/pod.vim
unlet b:current_syntax
if exists("perl_fold")
syn region perlPOD start="^=[a-z]" end="^=cut"
contains= Pod,perlTodo keepend fold
else
syn region perlPOD start="^=[a-z]" end="^=cut"
contains= Pod,perlTodo keepend
endif
else
" Use only the bare minimum of rules
if exists("perl_fold")
syn region perlPOD start="^=[a-z]" end="^=cut" fold
else
syn region perlPOD start="^=[a-z]" end="^=cut"
endif
endif
-=-=-=-=-=-=-
annoyingly enough, i couldn't figure out how to get it to actually turn
on the full pod syntax rules, either for my xs file or normal perl
files -- it just treats the pod section like comments.
anyway, hope that's helpful. if anybody knows what i did wrong, or
wants to illustrate how emacs is so much simpler and i should be using
that instead[1], feel free.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]