Sync from the branch.
[MacVim.git] / runtime / ftplugin / perl.vim
blob3f3e570b8ef69cef1d5747d1f78cbcc833046a57
1 " Vim filetype plugin file
2 " Language:     Perl
3 " Maintainer:   Dan Sharp <dwsharp at hotmail dot com>
4 " Last Change:  2007 Nov 30
5 " URL:          http://mywebpage.netscape.com/sharppeople/vim/ftplugin
7 if exists("b:did_ftplugin") | finish | endif
8 let b:did_ftplugin = 1
10 " Make sure the continuation lines below do not cause problems in
11 " compatibility mode.
12 let s:save_cpo = &cpo
13 set cpo-=C
15 setlocal formatoptions+=crq
17 setlocal comments=:#
18 setlocal commentstring=#%s
20 " Change the browse dialog on Win32 to show mainly Perl-related files
21 if has("gui_win32")
22     let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
23                        \ "Perl Modules (*.pm)\t*.pm\n" .
24                        \ "Perl Documentation Files (*.pod)\t*.pod\n" .
25                        \ "All Files (*.*)\t*.*\n"
26 endif
28 " Provided by Ned Konz <ned at bike-nomad dot com>
29 "---------------------------------------------
30 setlocal include=\\<\\(use\\\|require\\)\\>
31 setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
32 setlocal define=[^A-Za-z_]
34 " The following line changes a global variable but is necessary to make
35 " gf and similar commands work.  The change to iskeyword was incorrect.
36 " Thanks to Andrew Pimlott for pointing out the problem. If this causes a
37 " problem for you, add an after/ftplugin/perl.vim file that contains
38 "       set isfname-=:
39 set isfname+=:
40 "setlocal iskeyword=48-57,_,A-Z,a-z,:
42 " Set this once, globally.
43 if !exists("perlpath")
44     if executable("perl")
45       try
46         if &shellxquote != '"'
47             let perlpath = system('perl -e "print join(q/,/,@INC)"')
48         else
49             let perlpath = system("perl -e 'print join(q/,/,@INC)'")
50         endif
51         let perlpath = substitute(perlpath,',.$',',,','')
52       catch /E145:/
53         let perlpath = ".,,"
54       endtry
55     else
56         " If we can't call perl to get its path, just default to using the
57         " current directory and the directory of the current file.
58         let perlpath = ".,,"
59     endif
60 endif
62 let &l:path=perlpath
63 "---------------------------------------------
65 " Undo the stuff we changed.
66 let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf<" .
67             \         " | unlet! b:browsefilter"
69 " Restore the saved compatibility options.
70 let &cpo = s:save_cpo