Proposed filetype detection for Perl/Pod 6

29 views
Skip to first unread message

Hinrik Örn Sigurðsson

unread,
Sep 2, 2009, 2:28:11 PM9/2/09
to vim-...@googlegroups.com
Currently, to make sure that vim associates the 'perl6' filetype with
your Perl 6 code, you have to put a "vim: filetype=perl6" modeline
near the beginning/end of your source file. This is suboptimal,
however, because when vim processes the modeline, it has *already*
sourced the ftplugin/syntax/indent files for Perl 5. Aside from
performance reasons, this poses a problem for Perl 6's ftplugin file
because where they differ, the Perl 6 one must undo some changes made
by the Perl 5 one.

So, to do this properly, we have to patch vim's filetype.vim and
scripts.vim, which handle filetype detection. I have made the
following patches, and they work very well at detecting Perl/Pod 6.

filetype.vim.diff: http://gist.github.com/179863
scripts.vim.diff: http://gist.github.com/179865

If you don't want to apply the patches or wait for vim to include
them, the same can be accomplished by putting the code into
~/.vim/filetype.vim and ~/.vim/scripts.vim on your machine.

Andy Lester

unread,
Sep 2, 2009, 2:33:00 PM9/2/09
to vim-...@googlegroups.com

On Sep 2, 2009, at 1:28 PM, Hinrik Örn Sigurðsson wrote:

> This is suboptimal,
> however, because when vim processes the modeline, it has *already*
> sourced the ftplugin/syntax/indent files for Perl 5


So the key is, we're looking for suggestions on how to do it better.
I also fear that the "use v6/whatever" will not be robust enough.

--
Andy Lester => an...@petdance.com => www.theworkinggeek.com => AIM:petdance


Hinrik Örn Sigurðsson

unread,
Sep 2, 2009, 2:38:48 PM9/2/09
to vim-...@googlegroups.com
On Wed, Sep 2, 2009 at 6:33 PM, Andy Lester<an...@petdance.com> wrote:
> So the key is, we're looking for suggestions on how to do it better.
> I also fear that the "use v6/whatever" will not be robust enough.
>
> --
> Andy Lester => an...@petdance.com => www.theworkinggeek.com => AIM:petdance

As far as I know, this logic is what has been proposed for the Perl 6
specification. That is, all Perl files will be considered to be Perl 5
unless the first like of code is "use v6" or a
grammar/class/module/role declaration.

Reply all
Reply to author
Forward
0 new messages