xref: /vim-8.2.3635/runtime/ftplugin/perl.vim (revision 8c8de839)
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
6
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
16
17setlocal comments=:#
18setlocal commentstring=#%s
19
20" Change the browse dialog on Win32 to show mainly Perl-related files
21if 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"
26endif
27
28" Provided by Ned Konz <ned at bike-nomad dot com>
29"---------------------------------------------
30setlocal include=\\<\\(use\\\|require\\)\\>
31setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','')
32setlocal define=[^A-Za-z_]
33
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-=:
39set isfname+=:
40"setlocal iskeyword=48-57,_,A-Z,a-z,:
41
42" Set this once, globally.
43if !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
60endif
61
62let &l:path=perlpath
63"---------------------------------------------
64
65" Undo the stuff we changed.
66let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf<" .
67	    \	      " | unlet! b:browsefilter"
68
69" Restore the saved compatibility options.
70let &cpo = s:save_cpo
71