0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

Add option guard and undo

Signed-off-by: Rob B <github@0x7e.net>
This commit is contained in:
Rob B 2025-07-02 19:10:34 +10:00
parent c8e39c0127
commit a5da18c6ab

View File

@ -49,26 +49,33 @@ if !exists('*' .. expand('<SID>') .. 'GoKeywordPrg')
endfunc
endif
noremap <silent> <buffer> ]] <Cmd>call <SID>GoFindSection('next_start', v:count1)<CR>
noremap <silent> <buffer> ][ <Cmd>call <SID>GoFindSection('next_end', v:count1)<CR>
noremap <silent> <buffer> [[ <Cmd>call <SID>GoFindSection('prev_start', v:count1)<CR>
noremap <silent> <buffer> [] <Cmd>call <SID>GoFindSection('prev_end', v:count1)<CR>
if !exists("no_plugin_maps") && !exists("no_go_maps")
noremap <silent> <buffer> ]] <Cmd>call <SID>GoFindSection('next_start', v:count1)<CR>
noremap <silent> <buffer> ][ <Cmd>call <SID>GoFindSection('next_end', v:count1)<CR>
noremap <silent> <buffer> [[ <Cmd>call <SID>GoFindSection('prev_start', v:count1)<CR>
noremap <silent> <buffer> [] <Cmd>call <SID>GoFindSection('prev_end', v:count1)<CR>
let b:undo_ftplugin ..= ''
\ . '| unmap <buffer> ]]'
\ . '| unmap <buffer> ]['
\ . '| unmap <buffer> [['
\ . '| unmap <buffer> []'
endif
function! <SID>GoFindSection(dir, count)
mark '
let c = a:count
while c > 0
if a:dir == 'next_start'
keepjumps call search('^\(type\|func\)\>', 'W')
elseif a:dir == 'next_end'
keepjumps call search('^}', 'W')
elseif a:dir == 'prev_start'
keepjumps call search('^\(type\|func\)\>', 'bW')
elseif a:dir == 'prev_end'
keepjumps call search('^}', 'bW')
endif
let c -= 1
endwhile
mark '
let c = a:count
while c > 0
if a:dir == 'next_start'
keepjumps call search('^\(type\|func\)\>', 'W')
elseif a:dir == 'next_end'
keepjumps call search('^}', 'W')
elseif a:dir == 'prev_start'
keepjumps call search('^\(type\|func\)\>', 'bW')
elseif a:dir == 'prev_end'
keepjumps call search('^}', 'bW')
endif
let c -= 1
endwhile
endfunction
let &cpo = s:cpo_save