blob: 2a905ab3545baa1500c1e35ce9bf70d7f033e4fe [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)
8" Last Change: 2021 Oct 19
9
10if exists("b:did_ftplugin")
11 finish
12endif
13
14let s:save_cpo = &cpo
15set cpo-=C
16
17setlocal comments=fb:=for\ comment
18setlocal commentstring==for\ comment\ %s
19
20let b:undo_ftplugin = "setl com< cms<"
21
22if exists("loaded_matchit") && !exists("b:match_words")
23 let b:match_words =
24 \ '^=pod\>:^=cut\>,' .
25 \ '^=begin\s\+\(\S\+\):^=end\s\+\1,' .
26 \ '^=over\>:^=item\>:^=back\>,' .
27 \ '[IBCLEFSXZ]<<\%(\s\+\|$\)\@=:\%(\s\+\|^\)\@<=>>,' .
28 \ '[IBCLEFSXZ]<:>'
29 let b:undo_ftplugin .= " | unlet! b:match_words"
30endif
31
32if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
33 let b:browsefilter = "POD Source Files (*.pod)\t*.pod\n" .
34 \ "Perl Source Files (*.pl)\t*.pl\n" .
35 \ "Perl Modules (*.pm)\t*.pm\n" .
36 \ "All Files (*.*)\t*.*\n"
37 let b:undo_ftplugin .= " | unlet! b:browsefilter"
38endif
39
40function! s:jumpToSection(backwards)
41 let flags = a:backwards ? '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
50endfunction
51
52if !exists("no_plugin_maps") && !exists("no_pod_maps")
53 nnoremap <silent> <buffer> ]] <Cmd>call <SID>jumpToSection()<CR>
54 vnoremap <silent> <buffer> ]] <Cmd>call <SID>jumpToSection()<CR>
55 nnoremap <silent> <buffer> ][ <Cmd>call <SID>jumpToSection()<CR>
56 vnoremap <silent> <buffer> ][ <Cmd>call <SID>jumpToSection()<CR>
57 nnoremap <silent> <buffer> [[ <Cmd>call <SID>jumpToSection(1)<CR>
58 vnoremap <silent> <buffer> [[ <Cmd>call <SID>jumpToSection(1)<CR>
59 nnoremap <silent> <buffer> [] <Cmd>call <SID>jumpToSection(1)<CR>
60 vnoremap <silent> <buffer> [] <Cmd>call <SID>jumpToSection(1)<CR>
61 let b:undo_ftplugin .=
62 \ " | silent! exe 'nunmap <buffer> ]]' | silent! exe 'vunmap <buffer> ]]'" .
63 \ " | silent! exe 'nunmap <buffer> ][' | silent! exe 'vunmap <buffer> ]['" .
64 \ " | silent! exe 'nunmap <buffer> ]]' | silent! exe 'vunmap <buffer> ]]'" .
65 \ " | silent! exe 'nunmap <buffer> []' | silent! exe 'vunmap <buffer> []'"
66endif
67
68let &cpo = s:save_cpo
69unlet s:save_cpo
70
71" vim: set expandtab: