mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
runtime(go): add section movement mappings to ftplugin
closes: #17641 Signed-off-by: Rob B <github@0x7e.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
651edf33eb
commit
5ecee30dcd
@ -6,6 +6,7 @@
|
|||||||
" 2025 Mar 07 by Vim Project (add formatprg and keywordprg option #16804)
|
" 2025 Mar 07 by Vim Project (add formatprg and keywordprg option #16804)
|
||||||
" 2025 Mar 18 by Vim Project (use :term for 'keywordprg' #16911)
|
" 2025 Mar 18 by Vim Project (use :term for 'keywordprg' #16911)
|
||||||
" 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121)
|
" 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121)
|
||||||
|
" 2025 Jul 02 by Vim Project (add section movement mappings #17641)
|
||||||
|
|
||||||
if exists('b:did_ftplugin')
|
if exists('b:did_ftplugin')
|
||||||
finish
|
finish
|
||||||
@ -29,10 +30,10 @@ let b:undo_ftplugin = 'setl fo< com< cms< fp< kp<'
|
|||||||
|
|
||||||
if get(g:, 'go_recommended_style', 1)
|
if get(g:, 'go_recommended_style', 1)
|
||||||
setlocal noexpandtab softtabstop=0 shiftwidth=0
|
setlocal noexpandtab softtabstop=0 shiftwidth=0
|
||||||
let b:undo_ftplugin ..= ' | setl et< sts< sw<'
|
let b:undo_ftplugin .= ' | setl et< sts< sw<'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('*' .. expand('<SID>') .. 'GoKeywordPrg')
|
if !exists('*' . expand('<SID>') . 'GoKeywordPrg')
|
||||||
func! s:GoKeywordPrg()
|
func! s:GoKeywordPrg()
|
||||||
let temp_isk = &l:iskeyword
|
let temp_isk = &l:iskeyword
|
||||||
setl iskeyword+=.
|
setl iskeyword+=.
|
||||||
@ -49,6 +50,35 @@ if !exists('*' .. expand('<SID>') .. 'GoKeywordPrg')
|
|||||||
endfunc
|
endfunc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
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
|
||||||
|
endfunction
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user