pod.vim 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: 2021 Oct 19
  9. if exists("b:did_ftplugin")
  10. finish
  11. endif
  12. let s:save_cpo = &cpo
  13. set cpo-=C
  14. setlocal comments=fb:=for\ comment
  15. setlocal commentstring==for\ comment\ %s
  16. let b:undo_ftplugin = "setl com< cms<"
  17. if exists("loaded_matchit") && !exists("b:match_words")
  18. let b:match_words =
  19. \ '^=pod\>:^=cut\>,' .
  20. \ '^=begin\s\+\(\S\+\):^=end\s\+\1,' .
  21. \ '^=over\>:^=item\>:^=back\>,' .
  22. \ '[IBCLEFSXZ]<<\%(\s\+\|$\)\@=:\%(\s\+\|^\)\@<=>>,' .
  23. \ '[IBCLEFSXZ]<:>'
  24. let b:undo_ftplugin .= " | unlet! b:match_words"
  25. endif
  26. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  27. let b:browsefilter = "POD Source Files (*.pod)\t*.pod\n" .
  28. \ "Perl Source Files (*.pl)\t*.pl\n" .
  29. \ "Perl Modules (*.pm)\t*.pm\n" .
  30. \ "All Files (*.*)\t*.*\n"
  31. let b:undo_ftplugin .= " | unlet! b:browsefilter"
  32. endif
  33. function! s:jumpToSection(backwards)
  34. let flags = a:backwards ? 'bsWz' : 'sWz'
  35. if has('syntax_items')
  36. let skip = "synIDattr(synID(line('.'), col('.'), 1), 'name') !~# '\\<podCommand\\>'"
  37. else
  38. let skip = ''
  39. endif
  40. for i in range(v:count1)
  41. call search('^=\a', flags, 0, 0, skip)
  42. endfor
  43. endfunction
  44. if !exists("no_plugin_maps") && !exists("no_pod_maps")
  45. nnoremap <silent> <buffer> ]] <Cmd>call <SID>jumpToSection()<CR>
  46. vnoremap <silent> <buffer> ]] <Cmd>call <SID>jumpToSection()<CR>
  47. nnoremap <silent> <buffer> ][ <Cmd>call <SID>jumpToSection()<CR>
  48. vnoremap <silent> <buffer> ][ <Cmd>call <SID>jumpToSection()<CR>
  49. nnoremap <silent> <buffer> [[ <Cmd>call <SID>jumpToSection(1)<CR>
  50. vnoremap <silent> <buffer> [[ <Cmd>call <SID>jumpToSection(1)<CR>
  51. nnoremap <silent> <buffer> [] <Cmd>call <SID>jumpToSection(1)<CR>
  52. vnoremap <silent> <buffer> [] <Cmd>call <SID>jumpToSection(1)<CR>
  53. let b:undo_ftplugin .=
  54. \ " | silent! exe 'nunmap <buffer> ]]' | silent! exe 'vunmap <buffer> ]]'" .
  55. \ " | silent! exe 'nunmap <buffer> ][' | silent! exe 'vunmap <buffer> ]['" .
  56. \ " | silent! exe 'nunmap <buffer> ]]' | silent! exe 'vunmap <buffer> ]]'" .
  57. \ " | silent! exe 'nunmap <buffer> []' | silent! exe 'vunmap <buffer> []'"
  58. endif
  59. let &cpo = s:save_cpo
  60. unlet s:save_cpo
  61. " vim: set expandtab: