As per the example, I can use:
nmap <silent> gd <Plug>(coc-definition)
for go to definition. But I also use GNU Global for some smaller projects, and it's like this:
nmap <silent>gd :cs find g <C-R>=expand("<cword>")<CR><CR>
And there is the dumb VIM built-in gd.
So how can I combine them together, in the sequence of coc -> Global -> built-in? In other words, if the coc-definition finds something, jump to it, otherwise try another command and jump to the definition, and finally fallback to the built-in gq.
function! s:GoToDefinition()
if CocAction('jumpDefinition')
return v:true
endif
let ret = execute("silent! normal \<C-]>")
if ret =~ "Error" || ret =~ "閿欒"
call searchdecl(expand('<cword>'))
endif
endfunction
nmap <silent> gd :call <SID>GoToDefinition()<CR>
I'm using this function, gd will go by coc -> tags -> searchdecl. You can try something like this with global.
Thank you.
Most helpful comment
I'm using this function,
gdwill go by coc -> tags -> searchdecl. You can try something like this withglobal.