Skip to content

Commit

Permalink
Building tools for developing code with Perl6
Browse files Browse the repository at this point in the history
Incorporated Andy Lester's perl vim code with minor highlighting modification.
  • Loading branch information
Christopher Bottoms committed Feb 17, 2011
1 parent c71a4d3 commit 62ba486
Show file tree
Hide file tree
Showing 17 changed files with 3,522 additions and 84 deletions.
8 changes: 7 additions & 1 deletion .bashrc
Expand Up @@ -66,9 +66,15 @@ alias vim='vim -p'
#
# Perl
alias cdp='cd ~/workspace/Perl5'
alias cdr='cd ~/workspace/Rakudo'
alias cdw='cd ~/workspace'


#----------------------------------------
#
# Perl6
alias cdr='cd ~/workspace/Rakudo'
alias new6='~/bashpack/shell.dir/new6'

#----------------------------------------
#Print out usage history of 10 most used commands (see history command)
history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | head -n 10
Expand Down
120 changes: 61 additions & 59 deletions _vim/ftplugin/perl.vim
@@ -1,69 +1,71 @@
if ! exists("g:did_perl_statusline")
setlocal statusline+=%(\ %{StatusLineIndexLine()}%)
setlocal statusline+=%=
setlocal statusline+=%f\
setlocal statusline+=%P\ \ \ \
let g:did_perl_statusline = 1
endif
" Vim filetype plugin file
" Language: Perl
" Maintainer: Andy Lester <andy@petdance.com>
" Homepage: http://github.com/petdance/vim-perl
" Bugs/requests: http://github.com/petdance/vim-perl/issues
" Last Change: 2009-08-14

if has( 'perl' )
perl << EOP
use strict;
if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1

sub not_in {
my $area_type = shift;
return 'not in ' . $area_type;
}
" Make sure the continuation lines below do not cause problems in
" compatibility mode.
let s:save_cpo = &cpo
set cpo-=C

sub current_line_number {
my $curwin = $main::curwin;
my ( $line_number, $column ) = $curwin->Cursor;
return $line_number;
}
setlocal formatoptions+=crq
setlocal keywordprg=perldoc\ -f

sub current_document {
my $curbuf = $main::curbuf;
my @document = map { $curbuf->Get($_) } 0 .. $curbuf->Count;
return @document;
}
setlocal comments=:#
setlocal commentstring=#%s

sub current_area {
my $type = shift;
my $start_tag = shift;
my $end_tag = shift;
my @document = current_document();
my $line_number = current_line_number();
my $sub_name = not_in($type);
for my $i ( reverse ( 1 .. $line_number -1 ) ) {
my $line = $document[$i];
if ( $line =~ /^$start_tag\s+(\w+)/ ) {
$sub_name = $1;
last;
}elsif ( $line =~ /^$end_tag/ ){
last;
}
}
return $sub_name;
}
" Change the browse dialog on Win32 to show mainly Perl-related files
if has("gui_win32")
let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
\ "Perl Modules (*.pm)\t*.pm\n" .
\ "Perl Documentation Files (*.pod)\t*.pod\n" .
\ "All Files (*.*)\t*.*\n"
endif

sub current_sub {
my @document = current_document();
my $line_number = current_line_number();
my $sub_name = current_area('sub','sub','}');
my $section_name = current_area('section','#:','#\.');
my $pod_name = current_area('POD','=head1','=cut');
if($pod_name ne not_in('POD') ){
$section_name = 'POD';
$sub_name = $pod_name;
}
" Provided by Ned Konz <ned at bike-nomad dot com>
"---------------------------------------------
setlocal include=\\<\\(use\\\|require\\)\\>
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
setlocal define=[^A-Za-z_]

VIM::DoCommand "let subName='$line_number: $section_name ($sub_name) '";
}
EOP
" The following line changes a global variable but is necessary to make
" gf and similar commands work. The change to iskeyword was incorrect.
" Thanks to Andrew Pimlott for pointing out the problem. If this causes a
" problem for you, add an after/ftplugin/perl.vim file that contains
" set isfname-=:
set isfname+=:

function! StatusLineIndexLine()
perl current_sub()
return subName
endfunction
" Set this once, globally.
if !exists("perlpath")
if executable("perl")
try
if &shellxquote != '"'
let perlpath = system('perl -e "print join(q/,/,@INC)"')
else
let perlpath = system("perl -e 'print join(q/,/,@INC)'")
endif
let perlpath = substitute(perlpath,',.$',',,','')
catch /E145:/
let perlpath = ".,,"
endtry
else
" If we can't call perl to get its path, just default to using the
" current directory and the directory of the current file.
let perlpath = ".,,"
endif
endif

let &l:path=perlpath
"---------------------------------------------

" Undo the stuff we changed.
let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< kp<" .
\ " | unlet! b:browsefilter"

" Restore the saved compatibility options.
let &cpo = s:save_cpo
49 changes: 49 additions & 0 deletions _vim/ftplugin/perl6.vim
@@ -0,0 +1,49 @@
" Vim filetype plugin file
" Language: Perl 6
" Maintainer: Andy Lester <andy@petdance.com>
" Homepage: http://github.com/petdance/vim-perl
" Bugs/requests: http://github.com/petdance/vim-perl/issues
" Last Change: 2010-08-10
" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
"
" Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com>

if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1

" Make sure the continuation lines below do not cause problems in
" compatibility mode.
let s:save_cpo = &cpo
set cpo-=C

setlocal formatoptions+=crq
setlocal comments=:#
setlocal commentstring=#%s

" Change the browse dialog on Win32 to show mainly Perl-related files
if has("gui_win32")
let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
\ "Perl Modules (*.pm)\t*.pm\n" .
\ "Perl Documentation Files (*.pod)\t*.pod\n" .
\ "All Files (*.*)\t*.*\n"
endif

" Provided by Ned Konz <ned at bike-nomad dot com>
"---------------------------------------------
setlocal include=\\<\\(use\\\|require\\)\\>
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
setlocal define=[^A-Za-z_]

" The following line changes a global variable but is necessary to make
" gf and similar commands work. Thanks to Andrew Pimlott for pointing out
" the problem. If this causes a " problem for you, add an
" after/ftplugin/perl6.vim file that contains
" set isfname-=:
set isfname+=:

" Undo the stuff we changed.
let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk<" .
\ " | unlet! b:browsefilter"

" Restore the saved compatibility options.
let &cpo = s:save_cpo
69 changes: 69 additions & 0 deletions _vim/ftplugin/perl_statusbar.vim
@@ -0,0 +1,69 @@
if ! exists("g:did_perl_statusline")
setlocal statusline+=%(\ %{StatusLineIndexLine()}%)
setlocal statusline+=%=
setlocal statusline+=%f\
setlocal statusline+=%P\ \ \ \
let g:did_perl_statusline = 1
endif

if has( 'perl' )
perl << EOP
use strict;

sub not_in {
my $area_type = shift;
return 'not in ' . $area_type;
}

sub current_line_number {
my $curwin = $main::curwin;
my ( $line_number, $column ) = $curwin->Cursor;
return $line_number;
}

sub current_document {
my $curbuf = $main::curbuf;
my @document = map { $curbuf->Get($_) } 0 .. $curbuf->Count;
return @document;
}

sub current_area {
my $type = shift;
my $start_tag = shift;
my $end_tag = shift;
my @document = current_document();
my $line_number = current_line_number();
my $sub_name = not_in($type);
for my $i ( reverse ( 1 .. $line_number -1 ) ) {
my $line = $document[$i];
if ( $line =~ /^$start_tag\s+(\w+)/ ) {
$sub_name = $1;
last;
}elsif ( $line =~ /^$end_tag/ ){
last;
}
}
return $sub_name;
}

sub current_sub {
my @document = current_document();
my $line_number = current_line_number();
my $sub_name = current_area('sub','sub','}');
my $section_name = current_area('section','#:','#\.');
my $pod_name = current_area('POD','=head1','=cut');
if($pod_name ne not_in('POD') ){
$section_name = 'POD';
$sub_name = $pod_name;
}

VIM::DoCommand "let subName='$line_number: $section_name ($sub_name) '";
}
EOP

function! StatusLineIndexLine()
perl current_sub()
return subName
endfunction
endif

14 changes: 14 additions & 0 deletions _vim/ftplugin/xs.vim
@@ -0,0 +1,14 @@
" Vim filetype plugin file
" Language: XS (Perl extension interface language)
" Maintainer: Andy Lester <andy@petdance.com>
" Homepage: http://github.com/petdance/vim-perl
" Bugs/requests: http://github.com/petdance/vim-perl/issues
" Last Change: 2009-08-14

" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif

" Just use the C plugin for now.
runtime! ftplugin/c.vim ftplugin/c_*.vim ftplugin/c/*.vim

0 comments on commit 62ba486

Please sign in to comment.