Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 2 | " 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 Moolenaar | 9d98fe9 | 2013-08-03 18:35:36 +0200 | [diff] [blame] | 6 | " Last Change: 2013-07-21 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7 | |
| 8 | if exists("b:did_ftplugin") | finish | endif |
| 9 | let b:did_ftplugin = 1 |
| 10 | |
| 11 | " Make sure the continuation lines below do not cause problems in |
| 12 | " compatibility mode. |
| 13 | let s:save_cpo = &cpo |
| 14 | set cpo-=C |
| 15 | |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 16 | setlocal formatoptions-=t |
| 17 | setlocal formatoptions+=crqol |
Bram Moolenaar | e37d50a | 2008-08-06 17:06:04 +0000 | [diff] [blame] | 18 | setlocal keywordprg=perldoc\ -f |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 19 | |
| 20 | setlocal comments=:# |
| 21 | setlocal commentstring=#%s |
| 22 | |
| 23 | " Change the browse dialog on Win32 to show mainly Perl-related files |
| 24 | if 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" |
| 29 | endif |
| 30 | |
| 31 | " Provided by Ned Konz <ned at bike-nomad dot com> |
| 32 | "--------------------------------------------- |
Bram Moolenaar | 83c465c | 2005-12-16 21:53:56 +0000 | [diff] [blame] | 33 | setlocal include=\\<\\(use\\\|require\\)\\> |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 34 | setlocal includeexpr=substitute(substitute(substitute(v:fname,'::','/','g'),'->\*','',''),'$','.pm','') |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 35 | setlocal define=[^A-Za-z_] |
| 36 | |
| 37 | " The following line changes a global variable but is necessary to make |
| 38 | " gf and similar commands work. The change to iskeyword was incorrect. |
| 39 | " Thanks to Andrew Pimlott for pointing out the problem. If this causes a |
| 40 | " problem for you, add an after/ftplugin/perl.vim file that contains |
| 41 | " set isfname-=: |
| 42 | set isfname+=: |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 43 | set iskeyword+=: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 44 | |
| 45 | " Set this once, globally. |
| 46 | if !exists("perlpath") |
| 47 | if executable("perl") |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 48 | try |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 49 | 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 Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 55 | catch /E145:/ |
| 56 | let perlpath = ".,," |
| 57 | endtry |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 58 | 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 |
| 63 | endif |
| 64 | |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 65 | " 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. |
| 68 | if &l:path == "" |
| 69 | if &g:path == "" |
| 70 | let &l:path=perlpath |
| 71 | else |
| 72 | let &l:path=&g:path.",".perlpath |
| 73 | endif |
| 74 | else |
| 75 | let &l:path=&l:path.",".perlpath |
| 76 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 77 | "--------------------------------------------- |
| 78 | |
| 79 | " Undo the stuff we changed. |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 80 | let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< kp< path<" . |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 81 | \ " | unlet! b:browsefilter" |
| 82 | |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 83 | " proper matching for matchit plugin |
| 84 | let b:match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField' |
| 85 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 86 | " Restore the saved compatibility options. |
| 87 | let &cpo = s:save_cpo |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 88 | unlet s:save_cpo |