Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 1 | " Vim filetype plugin file |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame^] | 2 | " Language: Perl 6 |
| 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 |
| 6 | " Last Change: 2013-05-11 |
| 7 | " Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 8 | " |
| 9 | " Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com> |
| 10 | |
| 11 | if exists("b:did_ftplugin") | finish | endif |
| 12 | let b:did_ftplugin = 1 |
| 13 | |
| 14 | " Make sure the continuation lines below do not cause problems in |
| 15 | " compatibility mode. |
| 16 | let s:save_cpo = &cpo |
| 17 | set cpo-=C |
| 18 | |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame^] | 19 | setlocal formatoptions-=t |
| 20 | setlocal formatoptions+=crqol |
| 21 | setlocal keywordprg=p6doc |
| 22 | |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 23 | setlocal comments=:# |
| 24 | setlocal commentstring=#%s |
| 25 | |
| 26 | " Change the browse dialog on Win32 to show mainly Perl-related files |
| 27 | if has("gui_win32") |
| 28 | let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" . |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame^] | 29 | \ "Perl Modules (*.pm)\t*.pm\n" . |
| 30 | \ "Perl Documentation Files (*.pod)\t*.pod\n" . |
| 31 | \ "All Files (*.*)\t*.*\n" |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 32 | endif |
| 33 | |
| 34 | " Provided by Ned Konz <ned at bike-nomad dot com> |
| 35 | "--------------------------------------------- |
| 36 | setlocal include=\\<\\(use\\\|require\\)\\> |
| 37 | setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','') |
| 38 | setlocal define=[^A-Za-z_] |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 39 | |
| 40 | " The following line changes a global variable but is necessary to make |
| 41 | " gf and similar commands work. Thanks to Andrew Pimlott for pointing out |
| 42 | " the problem. If this causes a " problem for you, add an |
| 43 | " after/ftplugin/perl6.vim file that contains |
| 44 | " set isfname-=: |
| 45 | set isfname+=: |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame^] | 46 | setlocal iskeyword=48-57,_,A-Z,a-z,:,- |
| 47 | |
| 48 | " Set this once, globally. |
| 49 | if !exists("perlpath") |
| 50 | if executable("perl6") |
| 51 | try |
| 52 | if &shellxquote != '"' |
| 53 | let perlpath = system('perl6 -e "@*INC.join(q/,/).say"') |
| 54 | else |
| 55 | let perlpath = system("perl6 -e '@*INC.join(q/,/).say'") |
| 56 | endif |
| 57 | let perlpath = substitute(perlpath,',.$',',,','') |
| 58 | catch /E145:/ |
| 59 | let perlpath = ".,," |
| 60 | endtry |
| 61 | else |
| 62 | " If we can't call perl to get its path, just default to using the |
| 63 | " current directory and the directory of the current file. |
| 64 | let perlpath = ".,," |
| 65 | endif |
| 66 | endif |
| 67 | |
| 68 | let &l:path=perlpath |
| 69 | "--------------------------------------------- |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 70 | |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 71 | " Undo the stuff we changed. |
| 72 | let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk<" . |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame^] | 73 | \ " | unlet! b:browsefilter" |
Bram Moolenaar | 9de9997 | 2010-08-09 22:33:06 +0200 | [diff] [blame] | 74 | |
| 75 | " Restore the saved compatibility options. |
| 76 | let &cpo = s:save_cpo |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 77 | unlet s:save_cpo |