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