blob: e7acf654f3875cc2e3d2c814c2d3764105f6eba8 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02002" Language: Perl
3" Maintainer: vim-perl <vim-perl@googlegroups.com>
4" Homepage: http://github.com/vim-perl/vim-perl
5" Bugs/requests: http://github.com/vim-perl/vim-perl/issues
Bram Moolenaar37c64c72017-09-19 22:06:03 +02006" Last Change: 2015-02-09
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8if exists("b:did_ftplugin") | finish | endif
9let b:did_ftplugin = 1
10
11" Make sure the continuation lines below do not cause problems in
12" compatibility mode.
13let s:save_cpo = &cpo
14set cpo-=C
15
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020016setlocal formatoptions-=t
17setlocal formatoptions+=crqol
Bram Moolenaare37d50a2008-08-06 17:06:04 +000018setlocal keywordprg=perldoc\ -f
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
20setlocal comments=:#
21setlocal commentstring=#%s
22
23" Change the browse dialog on Win32 to show mainly Perl-related files
24if has("gui_win32")
25 let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
26 \ "Perl Modules (*.pm)\t*.pm\n" .
27 \ "Perl Documentation Files (*.pod)\t*.pod\n" .
28 \ "All Files (*.*)\t*.*\n"
29endif
30
31" Provided by Ned Konz <ned at bike-nomad dot com>
32"---------------------------------------------
Bram Moolenaar83c465c2005-12-16 21:53:56 +000033setlocal include=\\<\\(use\\\|require\\)\\>
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020034setlocal includeexpr=substitute(substitute(substitute(v:fname,'::','/','g'),'->\*','',''),'$','.pm','')
Bram Moolenaar071d4272004-06-13 20:20:40 +000035setlocal define=[^A-Za-z_]
Bram Moolenaar37c64c72017-09-19 22:06:03 +020036setlocal iskeyword+=:
Bram Moolenaar071d4272004-06-13 20:20:40 +000037
38" The following line changes a global variable but is necessary to make
Bram Moolenaar37c64c72017-09-19 22:06:03 +020039" gf and similar commands work. Thanks to Andrew Pimlott for pointing
40" out the problem. If this causes a problem for you, add an
41" after/ftplugin/perl.vim file that contains
Bram Moolenaar071d4272004-06-13 20:20:40 +000042" set isfname-=:
43set isfname+=:
Bram Moolenaar071d4272004-06-13 20:20:40 +000044
45" Set this once, globally.
46if !exists("perlpath")
47 if executable("perl")
Bram Moolenaar446cb832008-06-24 21:56:24 +000048 try
Bram Moolenaar071d4272004-06-13 20:20:40 +000049 if &shellxquote != '"'
50 let perlpath = system('perl -e "print join(q/,/,@INC)"')
51 else
52 let perlpath = system("perl -e 'print join(q/,/,@INC)'")
53 endif
54 let perlpath = substitute(perlpath,',.$',',,','')
Bram Moolenaar446cb832008-06-24 21:56:24 +000055 catch /E145:/
56 let perlpath = ".,,"
57 endtry
Bram Moolenaar071d4272004-06-13 20:20:40 +000058 else
59 " If we can't call perl to get its path, just default to using the
60 " current directory and the directory of the current file.
61 let perlpath = ".,,"
62 endif
63endif
64
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020065" Append perlpath to the existing path value, if it is set. Since we don't
66" use += to do it because of the commas in perlpath, we have to handle the
67" global / local settings, too.
68if &l:path == ""
69 if &g:path == ""
70 let &l:path=perlpath
71 else
72 let &l:path=&g:path.",".perlpath
73 endif
74else
75 let &l:path=&l:path.",".perlpath
76endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000077"---------------------------------------------
78
79" Undo the stuff we changed.
Bram Moolenaar37c64c72017-09-19 22:06:03 +020080let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk< isf< kp< path<" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000081 \ " | unlet! b:browsefilter"
82
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020083" proper matching for matchit plugin
84let b:match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField'
Bram Moolenaar37c64c72017-09-19 22:06:03 +020085let b:match_words = '\<if\>:\<elsif\>:\<else\>'
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020086
Bram Moolenaar071d4272004-06-13 20:20:40 +000087" Restore the saved compatibility options.
88let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010089unlet s:save_cpo