perl6.vim 2.5 KB

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