robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
db210dd2a4
master
1" Vim filetype plugin file 2" Language: Perl 3" Maintainer: vim-perl <vim-perl@googlegroups.com> (need to be subscribed to post) 4" Homepage: https://github.com/vim-perl/vim-perl 5" Bugs/requests: https://github.com/vim-perl/vim-perl/issues 6" License: Vim License (see :help license) 7" Last Change: 2021 Nov 10 8" 2023 Sep 07 by Vim Project (safety check: don't execute perl 9" from current directory) 10" 2024 Jan 14 by Vim Project (browsefilter) 11" 2024 May 24 by Riley Bruins <ribru17@gmail.com> ('commentstring') 12 13if exists ( "b:did_ftplugin" ) |finish |endif 14let b: did_ftplugin = 1 15 16" Make sure the continuation lines below do not cause problems in 17" compatibility mode. 18let s: save_cpo = & cpo 19set cpo -= C 20 21setlocal formatoptions -= t 22setlocal formatoptions += crqol 23setlocal keywordprg = perldoc\ -f 24 25setlocal comments = :# 26setlocal commentstring = #\ %s 27 28" Provided by Ned Konz <ned at bike-nomad dot com> 29"--------------------------------------------- 30setlocal include = \\<\\(use\\\|require\\)\\> 31" '+' is removed to support plugins in Catalyst or DBIx::Class 32" where the leading plus indicates a fully-qualified module name. 33setlocal includeexpr = substitute (substitute(substitute(substitute(v:fname,'+','',''),'::','/','g'),'->\*','',''),'$','.pm','') 34setlocal define = [^A-Za-z_] 35setlocal iskeyword += : 36 37" The following line changes a global variable but is necessary to make 38" gf and similar commands work. Thanks to Andrew Pimlott for pointing 39" out the problem. 40let s: old_isfname = & isfname 41set isfname += : 42let s: new_isfname = & isfname 43 44augroup perl_global_options 45au ! 46exe "au BufEnter * if &filetype == 'perl' | let &isfname = '" . s: new_isfname . "' | endif" 47exe "au BufLeave * if &filetype == 'perl' | let &isfname = '" . s: old_isfname . "' | endif" 48augroup END 49 50" Undo the stuff we changed. 51let b: undo_ftplugin = "setlocal fo< kp< com< cms< inc< inex< def< isk<" . 52 \" | let &isfname = '" . s: old_isfname . "'" 53 54if get ( g:, 'perl_fold' , 0 ) 55setlocal foldmethod = syntax 56let b: undo_ftplugin .= " | setlocal fdm<" 57endif 58 59" Set this once, globally. 60if ! exists ( "perlpath" ) 61" safety check: don't execute perl binary by default 62if dist#vim#IsSafeExecutable ( 'perl' , 'perl' ) 63try 64if & shellxquote != '"' 65let perlpath = system ( 'perl -e "print join(q/,/,@INC)"' ) 66else 67let perlpath = system ( "perl -e 'print join(q/,/,@INC)'" ) 68endif 69let perlpath = substitute ( perlpath , ',.$' , ',,' , '' ) 70catch /E145:/ 71let perlpath = ".,," 72endtry 73else 74" If we can't call perl to get its path, just default to using the 75" current directory and the directory of the current file. 76let perlpath = ".,," 77endif 78endif 79 80" Append perlpath to the existing path value, if it is set. Since we don't 81" use += to do it because of the commas in perlpath, we have to handle the 82" global / local settings, too. 83if & l: path == "" 84if & g: path == "" 85let & l: path = perlpath 86else 87let & l: path =& g: path . "," . perlpath 88endif 89else 90let & l: path =& l: path . "," . perlpath 91endif 92 93let b: undo_ftplugin .= " | setlocal pa<" 94"--------------------------------------------- 95 96" Change the browse dialog to show mainly Perl-related files 97if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 98let b: browsefilter = "Perl Source Files (*.pl)\t*.pl\n" . 99 \"Perl Modules (*.pm)\t*.pm\n" . 100 \"Perl Documentation Files (*.pod)\t*.pod\n" 101if has ( "win32" ) 102let b: browsefilter .= "All Files (*.*)\t*\n" 103else 104let b: browsefilter .= "All Files (*)\t*\n" 105endif 106let b: undo_ftplugin .= " | unlet! b:browsefilter" 107endif 108 109" Proper matching for matchit plugin 110if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 111let b: match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField' 112let b: match_words = '\<if\>:\<elsif\>:\<else\>' 113let b: undo_ftplugin .= " | unlet! b:match_words b:match_skip" 114endif 115 116" Restore the saved compatibility options. 117let & cpo = s: save_cpo 118unlet s: save_cpo s: old_isfname s: new_isfname