blob: fbfc0e5f8112aaa238d7535e543a80d46d8048cf [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
Bram Moolenaar9de99972010-08-09 22:33:06 +02002" Language: Perl
3" Maintainer: Andy Lester <andy@petdance.com>
4" URL: http://github.com/petdance/vim-perl
Bram Moolenaar84f72352012-03-11 15:57:40 +01005" Last Change: 2012 Mar 11
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7if exists("b:did_ftplugin") | finish | endif
8let b:did_ftplugin = 1
9
10" Make sure the continuation lines below do not cause problems in
11" compatibility mode.
12let s:save_cpo = &cpo
13set cpo-=C
14
15setlocal formatoptions+=crq
Bram Moolenaare37d50a2008-08-06 17:06:04 +000016setlocal keywordprg=perldoc\ -f
Bram Moolenaar071d4272004-06-13 20:20:40 +000017
18setlocal comments=:#
19setlocal commentstring=#%s
20
21" Change the browse dialog on Win32 to show mainly Perl-related files
22if has("gui_win32")
23 let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
24 \ "Perl Modules (*.pm)\t*.pm\n" .
25 \ "Perl Documentation Files (*.pod)\t*.pod\n" .
26 \ "All Files (*.*)\t*.*\n"
27endif
28
29" Provided by Ned Konz <ned at bike-nomad dot com>
30"---------------------------------------------
Bram Moolenaar83c465c2005-12-16 21:53:56 +000031setlocal include=\\<\\(use\\\|require\\)\\>
Bram Moolenaar071d4272004-06-13 20:20:40 +000032setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
33setlocal define=[^A-Za-z_]
34
35" The following line changes a global variable but is necessary to make
36" gf and similar commands work. The change to iskeyword was incorrect.
37" Thanks to Andrew Pimlott for pointing out the problem. If this causes a
38" problem for you, add an after/ftplugin/perl.vim file that contains
39" set isfname-=:
40set isfname+=:
41"setlocal iskeyword=48-57,_,A-Z,a-z,:
42
43" Set this once, globally.
44if !exists("perlpath")
45 if executable("perl")
Bram Moolenaar446cb832008-06-24 21:56:24 +000046 try
Bram Moolenaar071d4272004-06-13 20:20:40 +000047 if &shellxquote != '"'
48 let perlpath = system('perl -e "print join(q/,/,@INC)"')
49 else
50 let perlpath = system("perl -e 'print join(q/,/,@INC)'")
51 endif
52 let perlpath = substitute(perlpath,',.$',',,','')
Bram Moolenaar446cb832008-06-24 21:56:24 +000053 catch /E145:/
54 let perlpath = ".,,"
55 endtry
Bram Moolenaar071d4272004-06-13 20:20:40 +000056 else
57 " If we can't call perl to get its path, just default to using the
58 " current directory and the directory of the current file.
59 let perlpath = ".,,"
60 endif
61endif
62
63let &l:path=perlpath
64"---------------------------------------------
65
66" Undo the stuff we changed.
Bram Moolenaare37d50a2008-08-06 17:06:04 +000067let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< kp<" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000068 \ " | unlet! b:browsefilter"
69
70" Restore the saved compatibility options.
71let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010072unlet s:save_cpo