Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 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) |
dkearns | 4e554d2 | 2023-09-09 03:16:03 +1000 | [diff] [blame] | 8 | " Last Change: 2023 Jul 05 |
Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 9 | |
| 10 | if exists("b:did_ftplugin") |
dkearns | 4e554d2 | 2023-09-09 03:16:03 +1000 | [diff] [blame] | 11 | finish |
Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 12 | endif |
dkearns | 4e554d2 | 2023-09-09 03:16:03 +1000 | [diff] [blame] | 13 | let b:did_ftplugin = 1 |
Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 14 | |
| 15 | let s:save_cpo = &cpo |
| 16 | set cpo-=C |
| 17 | |
| 18 | setlocal comments=fb:=for\ comment |
| 19 | setlocal commentstring==for\ comment\ %s |
| 20 | |
| 21 | let b:undo_ftplugin = "setl com< cms<" |
| 22 | |
| 23 | if exists("loaded_matchit") && !exists("b:match_words") |
| 24 | let b:match_words = |
| 25 | \ '^=pod\>:^=cut\>,' . |
| 26 | \ '^=begin\s\+\(\S\+\):^=end\s\+\1,' . |
| 27 | \ '^=over\>:^=item\>:^=back\>,' . |
| 28 | \ '[IBCLEFSXZ]<<\%(\s\+\|$\)\@=:\%(\s\+\|^\)\@<=>>,' . |
| 29 | \ '[IBCLEFSXZ]<:>' |
| 30 | let b:undo_ftplugin .= " | unlet! b:match_words" |
| 31 | endif |
| 32 | |
| 33 | if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
| 34 | let b:browsefilter = "POD Source Files (*.pod)\t*.pod\n" . |
| 35 | \ "Perl Source Files (*.pl)\t*.pl\n" . |
| 36 | \ "Perl Modules (*.pm)\t*.pm\n" . |
| 37 | \ "All Files (*.*)\t*.*\n" |
| 38 | let b:undo_ftplugin .= " | unlet! b:browsefilter" |
| 39 | endif |
| 40 | |
dkearns | 4e554d2 | 2023-09-09 03:16:03 +1000 | [diff] [blame] | 41 | function s:jumpToSection(direction) |
| 42 | let flags = a:direction == "backward" ? "bsWz" : "sWz" |
| 43 | if has("syntax_items") |
Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 44 | let skip = "synIDattr(synID(line('.'), col('.'), 1), 'name') !~# '\\<podCommand\\>'" |
| 45 | else |
dkearns | 4e554d2 | 2023-09-09 03:16:03 +1000 | [diff] [blame] | 46 | let skip = "" |
Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 47 | endif |
| 48 | for i in range(v:count1) |
| 49 | call search('^=\a', flags, 0, 0, skip) |
| 50 | endfor |
| 51 | endfunction |
| 52 | |
| 53 | if !exists("no_plugin_maps") && !exists("no_pod_maps") |
dkearns | 4e554d2 | 2023-09-09 03:16:03 +1000 | [diff] [blame] | 54 | for s:mode in ["n", "o", "x"] |
| 55 | for s:lhs in ["]]", "]["] |
| 56 | execute s:mode . "noremap <silent> <buffer> " . s:lhs . " <Cmd>call <SID>jumpToSection('forward')<CR>" |
| 57 | let b:undo_ftplugin .= " | silent! execute '" . s:mode . "unmap <buffer> " . s:lhs . "'" |
| 58 | endfor |
| 59 | for s:lhs in ["[[", "[]"] |
| 60 | execute s:mode . "noremap <silent> <buffer> " . s:lhs . " <Cmd>call <SID>jumpToSection('backward')<CR>" |
| 61 | let b:undo_ftplugin .= " | silent! execute '" . s:mode . "unmap <buffer> " . s:lhs . "'" |
| 62 | endfor |
| 63 | endfor |
| 64 | unlet s:mode s:lhs |
Bram Moolenaar | 8c1b8cb | 2022-06-14 17:41:28 +0100 | [diff] [blame] | 65 | endif |
| 66 | |
| 67 | let &cpo = s:save_cpo |
| 68 | unlet s:save_cpo |
| 69 | |
| 70 | " vim: set expandtab: |