blob: 61a4aa094a020eb31ed2e7fd61b4cbbd42ad9a12 [file] [log] [blame]
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +01001" 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)
dkearns4e554d22023-09-09 03:16:03 +10008" Last Change: 2023 Jul 05
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +01009
10if exists("b:did_ftplugin")
dkearns4e554d22023-09-09 03:16:03 +100011 finish
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010012endif
dkearns4e554d22023-09-09 03:16:03 +100013let b:did_ftplugin = 1
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010014
15let s:save_cpo = &cpo
16set cpo-=C
17
18setlocal comments=fb:=for\ comment
19setlocal commentstring==for\ comment\ %s
20
21let b:undo_ftplugin = "setl com< cms<"
22
23if 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"
31endif
32
33if (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"
39endif
40
dkearns4e554d22023-09-09 03:16:03 +100041function s:jumpToSection(direction)
42 let flags = a:direction == "backward" ? "bsWz" : "sWz"
43 if has("syntax_items")
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010044 let skip = "synIDattr(synID(line('.'), col('.'), 1), 'name') !~# '\\<podCommand\\>'"
45 else
dkearns4e554d22023-09-09 03:16:03 +100046 let skip = ""
Bram Moolenaar8c1b8cb2022-06-14 17:41:28 +010047 endif
48 for i in range(v:count1)
49 call search('^=\a', flags, 0, 0, skip)
50 endfor
51endfunction
52
53if !exists("no_plugin_maps") && !exists("no_pod_maps")
dkearns4e554d22023-09-09 03:16:03 +100054 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 Moolenaar8c1b8cb2022-06-14 17:41:28 +010065endif
66
67let &cpo = s:save_cpo
68unlet s:save_cpo
69
70" vim: set expandtab: