perl.vim 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. " Vim filetype plugin file
  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
  6. " Last Change: 2015-02-09
  7. if exists("b:did_ftplugin") | finish | endif
  8. let b:did_ftplugin = 1
  9. " Make sure the continuation lines below do not cause problems in
  10. " compatibility mode.
  11. let s:save_cpo = &cpo
  12. set cpo-=C
  13. setlocal formatoptions-=t
  14. setlocal formatoptions+=crqol
  15. setlocal keywordprg=perldoc\ -f
  16. setlocal comments=:#
  17. setlocal commentstring=#%s
  18. " Change the browse dialog on Win32 to show mainly Perl-related files
  19. if has("gui_win32")
  20. let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
  21. \ "Perl Modules (*.pm)\t*.pm\n" .
  22. \ "Perl Documentation Files (*.pod)\t*.pod\n" .
  23. \ "All Files (*.*)\t*.*\n"
  24. endif
  25. " Provided by Ned Konz <ned at bike-nomad dot com>
  26. "---------------------------------------------
  27. setlocal include=\\<\\(use\\\|require\\)\\>
  28. setlocal includeexpr=substitute(substitute(substitute(v:fname,'::','/','g'),'->\*','',''),'$','.pm','')
  29. setlocal define=[^A-Za-z_]
  30. setlocal iskeyword+=:
  31. " The following line changes a global variable but is necessary to make
  32. " gf and similar commands work. Thanks to Andrew Pimlott for pointing
  33. " out the problem. If this causes a problem for you, add an
  34. " after/ftplugin/perl.vim file that contains
  35. " set isfname-=:
  36. set isfname+=:
  37. " Set this once, globally.
  38. if !exists("perlpath")
  39. if executable("perl")
  40. try
  41. if &shellxquote != '"'
  42. let perlpath = system('perl -e "print join(q/,/,@INC)"')
  43. else
  44. let perlpath = system("perl -e 'print join(q/,/,@INC)'")
  45. endif
  46. let perlpath = substitute(perlpath,',.$',',,','')
  47. catch /E145:/
  48. let perlpath = ".,,"
  49. endtry
  50. else
  51. " If we can't call perl to get its path, just default to using the
  52. " current directory and the directory of the current file.
  53. let perlpath = ".,,"
  54. endif
  55. endif
  56. " Append perlpath to the existing path value, if it is set. Since we don't
  57. " use += to do it because of the commas in perlpath, we have to handle the
  58. " global / local settings, too.
  59. if &l:path == ""
  60. if &g:path == ""
  61. let &l:path=perlpath
  62. else
  63. let &l:path=&g:path.",".perlpath
  64. endif
  65. else
  66. let &l:path=&l:path.",".perlpath
  67. endif
  68. "---------------------------------------------
  69. " Undo the stuff we changed.
  70. let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk< isf< kp< path<" .
  71. \ " | unlet! b:browsefilter"
  72. " proper matching for matchit plugin
  73. let b:match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField'
  74. let b:match_words = '\<if\>:\<elsif\>:\<else\>'
  75. " Restore the saved compatibility options.
  76. let &cpo = s:save_cpo
  77. unlet s:save_cpo