Friday, January 28, 2011

Re: Show method name in gutter

----- Original Message ----
> From: Alan Young <alansyoungiii@gmail.com>


> This works ok, but only for one file being edited per session. I know
> why, but I don't know how to fix it. Hopefully the list can help.
>
> I have this in my ~/.vim/after/ftplugin/perl.vim file (see
> https://github.com/harleypig/dot_vim for everything in context):
>
> " This makes the status line work *only* for the first perl file
> loaded, but
> " if I don't do it this way, the statusline has this check appended
> each time
> " the buffer is visited. How to fix this?
>
> if ! exists("g:did_perl_statusline")
> setlocal statusline+=%(\ %{StatusLineIndexLine()}%)
> let g:did_perl_statusline = 1
> endif
>
> if has( 'perl' )
> perl << EOP
> use strict;
>
> eval "use PPIx::IndexLines";
> my $error = $@;
>
> sub index_line {
>
> if ( $error ) {
>
> VIM::DoCommand "let subName='$error'";
>
> } else {
>
> my $curwin = $main::curwin;
> my $curbuf = $main::curbuf;
>
> # There's got to be a better way to slurp in the current buffer!
> my $document = join "\n", map { $curbuf->Get( $_ ) } 0 ..
> $curbuf->Count;
>
> my $ppi = PPIx::IndexLines->new( \$document );
> $ppi->index_lines;
> ( my $line, undef ) = $curwin->Cursor;
> my $sub_name = $ppi->line_type( $line );
> VIM::DoCommand "let subName='$line: $sub_name'";
>
> }
> }
>
> EOP
>
> function! StatusLineIndexLine()
> perl index_line()
> return subName
> endfunction
> endif

This looks like it would be a great start, but I'm working with some large files
and it's grinding my vim to a halt when I switch buffers. I might have to go
with a lightweight, but less correct option.

Cheers,
Ovid

--
Live and work overseas - http://overseas-exile.blogspot.com/
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://blogs.perl.org/users/ovid/
Twitter - http://twitter.com/OvidPerl/

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment