Created
October 31, 2015 01:59
-
-
Save anonymous/3443b10dd7984765e1e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup gojump | |
autocmd! | |
autocmd FileType go nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(func\)\>','goDeclaration','b','n')<CR> | |
autocmd FileType go xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(func\)\>','goDeclaration','b','v')<CR> | |
autocmd FileType go nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(func\)\>','goDeclaration','','n')<CR> | |
autocmd FileType go xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(func\)\>','goDeclaration','','v')<CR> | |
augroup END | |
function! s:searchsyn(pattern,syn,flags,mode) | |
norm! m' | |
if a:mode ==# 'v' | |
norm! gv | |
endif | |
let i = 0 | |
let cnt = v:count ? v:count : 1 | |
while i < cnt | |
let i = i + 1 | |
let line = line('.') | |
let col = col('.') | |
let pos = search(a:pattern,'W'.a:flags) | |
while pos != 0 && s:synname() !~# a:syn | |
let pos = search(a:pattern,'W'.a:flags) | |
endwhile | |
if pos == 0 | |
call cursor(line,col) | |
return | |
endif | |
endwhile | |
endfunction | |
function! s:synname() | |
return synIDattr(synID(line('.'),col('.'),0),'name') | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment