pod.vim 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. " Vim filetype plugin file
  2. " Language: Perl POD format
  3. " Maintainer: vim-perl <vim-perl@googlegroups.com>
  4. " Author: Doug Kearns <dougkearns@gmail.com>
  5. " Homepage: https://github.com/vim-perl/vim-perl
  6. " Bugs/requests: https://github.com/vim-perl/vim-perl/issues
  7. " License: Vim License (see :help license)
  8. " Last Change: 2023 Jul 05
  9. " Last Change: 2021 Oct 19
  10. " 2024 Jan 14 by Vim Project (browsefilter)
  11. if exists("b:did_ftplugin")
  12. finish
  13. endif
  14. let b:did_ftplugin = 1
  15. let s:save_cpo = &cpo
  16. set cpo-=C
  17. setlocal comments=fb:=for\ comment
  18. setlocal commentstring==for\ comment\ %s
  19. let b:undo_ftplugin = "setl com< cms<"
  20. if exists("loaded_matchit") && !exists("b:match_words")
  21. let b:match_words =
  22. \ '^=pod\>:^=cut\>,' .
  23. \ '^=begin\s\+\(\S\+\):^=end\s\+\1,' .
  24. \ '^=over\>:^=item\>:^=back\>,' .
  25. \ '[IBCLEFSXZ]<<\%(\s\+\|$\)\@=:\%(\s\+\|^\)\@<=>>,' .
  26. \ '[IBCLEFSXZ]<:>'
  27. let b:undo_ftplugin .= " | unlet! b:match_words"
  28. endif
  29. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  30. let b:browsefilter = "POD Source Files (*.pod)\t*.pod\n" .
  31. \ "Perl Source Files (*.pl)\t*.pl\n" .
  32. \ "Perl Modules (*.pm)\t*.pm\n"
  33. if has("win32")
  34. let b:browsefilter .= "All Files (*.*)\t*\n"
  35. else
  36. let b:browsefilter .= "All Files (*)\t*\n"
  37. endif
  38. let b:undo_ftplugin .= " | unlet! b:browsefilter"
  39. endif
  40. function s:jumpToSection(direction)
  41. let flags = a:direction == "backward" ? "bsWz" : "sWz"
  42. if has("syntax_items")
  43. let skip = "synIDattr(synID(line('.'), col('.'), 1), 'name') !~# '\\<podCommand\\>'"
  44. else
  45. let skip = ""
  46. endif
  47. for i in range(v:count1)
  48. call search('^=\a', flags, 0, 0, skip)
  49. endfor
  50. endfunction
  51. if !exists("no_plugin_maps") && !exists("no_pod_maps")
  52. for s:mode in ["n", "o", "x"]
  53. for s:lhs in ["]]", "]["]
  54. execute s:mode . "noremap <silent> <buffer> " . s:lhs . " <Cmd>call <SID>jumpToSection('forward')<CR>"
  55. let b:undo_ftplugin .= " | silent! execute '" . s:mode . "unmap <buffer> " . s:lhs . "'"
  56. endfor
  57. for s:lhs in ["[[", "[]"]
  58. execute s:mode . "noremap <silent> <buffer> " . s:lhs . " <Cmd>call <SID>jumpToSection('backward')<CR>"
  59. let b:undo_ftplugin .= " | silent! execute '" . s:mode . "unmap <buffer> " . s:lhs . "'"
  60. endfor
  61. endfor
  62. unlet s:mode s:lhs
  63. endif
  64. let &cpo = s:save_cpo
  65. unlet s:save_cpo
  66. " vim: set expandtab: