Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Sunday October 19, 2008
07:47 AM

Configuring Vim for Perl 6

[ #37698 ]

I've been playing around more with Perl 6 and have started to configure vim for it. First, download Parrot. After you have built it, change into the languages/perl6 directory and type make perl6. This will create a ./perl6 executable for you (don't type make install, though. This causes problems with future versions, as I've discovered).

Next, create the file ~/.vim/syntax/perl6.vim. This should contain Luke Palmer's Perl 6 vim syntax file (if there's a more up-to-date one, please post a comment). Then, in your ~/.vim/filetype.vim file, add the following entry:

augroup filetypedetect
    autocmd! BufRead,BufNewFile *.p6 setfiletype perl6
augroup END

That will associate any file with a .p6 extension with the Perl 6 filetype. Opening those files in vim will automatically apply the Perl 6 syntax to it.

While you should probably create a Perl 6 plugin, I have a (bad) habit of just dumping extra stuff in my .vimrc file. In that, I have the following (you'll need to adjust your path to the path of the ./perl6 executable):

au! FileType perl6 :call Perl6Mappings()

function! Perl6Mappings()
    map <buffer> <leader>r  :!~/code/parrot/languages/perl6/perl6 %<cr>
endfunction

I'll likely add more mappings in the future, but for now, this means that if you type ,r in vim while editing a Perl 6 file (assuming that you use the comma for your leader), you'll automatically run the program.

The tests are a bit more difficult. What I've done is this:

autocmd! BufRead,BufNewFile *.t   call s:PerlTestSetup()

function! s:PerlTestSetup()
    let n = 1
    let perl5 = 1
    if line("$") > 500
      let nmax = 500
    else
      let nmax = line("$")
    endif
    while n <= nmax
      if getline(n) =~ "use v6"
        setfiletype perl6
        let perl5 = 0
        break
      endif
      let n = n + 1
    endwhile
    if perl5 == 1
      setfiletype perl
      call PerlTestMappings()
    endif
endfunc

function! PerlTestMappings()
    noremap <buffer> ,r :!prove -vl %<cr>
    noremap <buffer> ,t :!prove -vl %<CR>
endfunction

It's a brute-force check to see if a .t file is Perl 6 or not. It uses a heuristic and can break. It also doesn't allow me to run my tests directly from the editor. It's a start, though.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.