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

runtime(go): add section movement

Signed-off-by: Rob B <github@0x7e.net>
This commit is contained in:
Rob B 2025-07-01 21:43:42 +10:00
parent 523f9f5898
commit c8e39c0127

View File

@ -49,6 +49,28 @@ 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>
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
endfunction
let &cpo = s:cpo_save
unlet s:cpo_save