| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Vim filetype plugin file | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | " Language:      Perl | 
					
						
							|  |  |  | " Maintainer:    vim-perl <vim-perl@googlegroups.com> | 
					
						
							| 
									
										
										
										
											2020-04-20 19:52:53 +02:00
										 |  |  | " Homepage:      https://github.com/vim-perl/vim-perl | 
					
						
							|  |  |  | " Bugs/requests: https://github.com/vim-perl/vim-perl/issues | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | " License:       Vim License (see :help license) | 
					
						
							|  |  |  | " Last Change:   2021 Nov 10 | 
					
						
							| 
									
										
										
										
											2023-09-09 03:16:03 +10:00
										 |  |  | "                2023 Sep 07 by Vim Project (safety check: don't execute perl | 
					
						
							|  |  |  | "                    from current directory) | 
					
						
							| 
									
										
										
										
											2024-01-14 20:59:02 +01:00
										 |  |  | "                2024 Jan 14 by Vim Project (browsefilter) | 
					
						
							| 
									
										
										
										
											2024-06-03 20:40:45 +02:00
										 |  |  | "                2024 May 24 by Riley Bruins <ribru17@gmail.com> ('commentstring') | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if exists("b:did_ftplugin") | finish | endif | 
					
						
							|  |  |  | let b:did_ftplugin = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Make sure the continuation lines below do not cause problems in | 
					
						
							|  |  |  | " compatibility mode. | 
					
						
							|  |  |  | let s:save_cpo = &cpo | 
					
						
							|  |  |  | set cpo-=C | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | setlocal formatoptions-=t | 
					
						
							|  |  |  | setlocal formatoptions+=crqol | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | setlocal keywordprg=perldoc\ -f | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | setlocal comments=:# | 
					
						
							| 
									
										
										
										
											2024-06-03 20:40:45 +02:00
										 |  |  | setlocal commentstring=#\ %s | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Provided by Ned Konz <ned at bike-nomad dot com> | 
					
						
							|  |  |  | "--------------------------------------------- | 
					
						
							| 
									
										
										
										
											2005-12-16 21:53:56 +00:00
										 |  |  | setlocal include=\\<\\(use\\\|require\\)\\> | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | " '+' is removed to support plugins in Catalyst or DBIx::Class | 
					
						
							|  |  |  | " where the leading plus indicates a fully-qualified module name. | 
					
						
							|  |  |  | setlocal includeexpr=substitute(substitute(substitute(substitute(v:fname,'+','',''),'::','/','g'),'->\*','',''),'$','.pm','') | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | setlocal define=[^A-Za-z_] | 
					
						
							| 
									
										
										
										
											2017-09-19 22:06:03 +02:00
										 |  |  | setlocal iskeyword+=: | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " The following line changes a global variable but is necessary to make | 
					
						
							| 
									
										
										
										
											2017-09-19 22:06:03 +02:00
										 |  |  | " gf and similar commands work. Thanks to Andrew Pimlott for pointing | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | " out the problem. | 
					
						
							|  |  |  | let s:old_isfname = &isfname | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | set isfname+=: | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | let s:new_isfname = &isfname | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | augroup perl_global_options | 
					
						
							|  |  |  |   au! | 
					
						
							|  |  |  |   exe "au BufEnter * if &filetype == 'perl' | let &isfname = '" . s:new_isfname . "' | endif" | 
					
						
							|  |  |  |   exe "au BufLeave * if &filetype == 'perl' | let &isfname = '" . s:old_isfname . "' | endif" | 
					
						
							|  |  |  | augroup END | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Undo the stuff we changed. | 
					
						
							|  |  |  | let b:undo_ftplugin = "setlocal fo< kp< com< cms< inc< inex< def< isk<" . | 
					
						
							|  |  |  |       \               " | let &isfname = '" .  s:old_isfname . "'" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if get(g:, 'perl_fold', 0) | 
					
						
							|  |  |  |   setlocal foldmethod=syntax | 
					
						
							|  |  |  |   let b:undo_ftplugin .= " | setlocal fdm<" | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Set this once, globally. | 
					
						
							|  |  |  | if !exists("perlpath") | 
					
						
							| 
									
										
										
										
											2023-09-06 20:41:25 +02:00
										 |  |  |     " safety check: don't execute perl binary by default | 
					
						
							| 
									
										
										
										
											2023-11-04 05:11:17 -04:00
										 |  |  |     if dist#vim#IsSafeExecutable('perl', 'perl') | 
					
						
							| 
									
										
										
										
											2008-06-24 21:56:24 +00:00
										 |  |  |       try | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 	if &shellxquote != '"' | 
					
						
							|  |  |  | 	    let perlpath = system('perl -e "print join(q/,/,@INC)"') | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	    let perlpath = system("perl -e 'print join(q/,/,@INC)'") | 
					
						
							|  |  |  | 	endif | 
					
						
							|  |  |  | 	let perlpath = substitute(perlpath,',.$',',,','') | 
					
						
							| 
									
										
										
										
											2008-06-24 21:56:24 +00:00
										 |  |  |       catch /E145:/ | 
					
						
							|  |  |  | 	let perlpath = ".,," | 
					
						
							|  |  |  |       endtry | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |     else | 
					
						
							|  |  |  | 	" If we can't call perl to get its path, just default to using the | 
					
						
							|  |  |  | 	" current directory and the directory of the current file. | 
					
						
							|  |  |  | 	let perlpath = ".,," | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | " Append perlpath to the existing path value, if it is set.  Since we don't | 
					
						
							|  |  |  | " use += to do it because of the commas in perlpath, we have to handle the | 
					
						
							|  |  |  | " global / local settings, too. | 
					
						
							|  |  |  | if &l:path == "" | 
					
						
							|  |  |  |     if &g:path == "" | 
					
						
							|  |  |  |         let &l:path=perlpath | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         let &l:path=&g:path.",".perlpath | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |     let &l:path=&l:path.",".perlpath | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | let b:undo_ftplugin .= " | setlocal pa<" | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | "--------------------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | " Change the browse dialog to show mainly Perl-related files | 
					
						
							|  |  |  | if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") | 
					
						
							|  |  |  |     let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" . | 
					
						
							|  |  |  | 		       \ "Perl Modules (*.pm)\t*.pm\n" . | 
					
						
							| 
									
										
										
										
											2024-01-14 20:59:02 +01:00
										 |  |  | 		       \ "Perl Documentation Files (*.pod)\t*.pod\n" | 
					
						
							|  |  |  |     if has("win32") | 
					
						
							|  |  |  | 	let b:browsefilter .= "All Files (*.*)\t*\n" | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  | 	let b:browsefilter .= "All Files (*)\t*\n" | 
					
						
							|  |  |  |     endif | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  |     let b:undo_ftplugin .= " | unlet! b:browsefilter" | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | " Proper matching for matchit plugin | 
					
						
							|  |  |  | if exists("loaded_matchit") && !exists("b:match_words") | 
					
						
							|  |  |  |     let b:match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField' | 
					
						
							|  |  |  |     let b:match_words = '\<if\>:\<elsif\>:\<else\>' | 
					
						
							|  |  |  |     let b:undo_ftplugin .= " | unlet! b:match_words b:match_skip" | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Restore the saved compatibility options. | 
					
						
							|  |  |  | let &cpo = s:save_cpo | 
					
						
							| 
									
										
										
										
											2022-06-14 17:41:28 +01:00
										 |  |  | unlet s:save_cpo s:old_isfname s:new_isfname |