|
5 | 5 | " Homepage: https://github.com/vim-perl/vim-perl |
6 | 6 | " Bugs/requests: https://github.com/vim-perl/vim-perl/issues |
7 | 7 | " License: Vim License (see :help license) |
8 | | -" Last Change: 2021 Oct 19 |
| 8 | +" Last Change: 2023 Jul 05 |
9 | 9 |
|
10 | 10 | if exists("b:did_ftplugin") |
11 | | - finish |
| 11 | + finish |
12 | 12 | endif |
| 13 | +let b:did_ftplugin = 1 |
13 | 14 |
|
14 | 15 | let s:save_cpo = &cpo |
15 | 16 | set cpo-=C |
@@ -37,32 +38,30 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
37 | 38 | let b:undo_ftplugin .= " | unlet! b:browsefilter" |
38 | 39 | endif |
39 | 40 |
|
40 | | -function! s:jumpToSection(backwards) |
41 | | - let flags = a:backwards ? 'bsWz' : 'sWz' |
42 | | - if has('syntax_items') |
| 41 | +function s:jumpToSection(direction) |
| 42 | + let flags = a:direction == "backward" ? "bsWz" : "sWz" |
| 43 | + if has("syntax_items") |
43 | 44 | let skip = "synIDattr(synID(line('.'), col('.'), 1), 'name') !~# '\\<podCommand\\>'" |
44 | 45 | else |
45 | | - let skip = '' |
| 46 | + let skip = "" |
46 | 47 | endif |
47 | 48 | for i in range(v:count1) |
48 | 49 | call search('^=\a', flags, 0, 0, skip) |
49 | 50 | endfor |
50 | 51 | endfunction |
51 | 52 |
|
52 | 53 | if !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> []'" |
| 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 |
66 | 65 | endif |
67 | 66 |
|
68 | 67 | let &cpo = s:save_cpo |
|
0 commit comments