Skip to content

Instantly share code, notes, and snippets.

@nametake
Created November 3, 2019 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nametake/7ccbb9aeef80b069363353b49ed5338f to your computer and use it in GitHub Desktop.
Save nametake/7ccbb9aeef80b069363353b49ed5338f to your computer and use it in GitHub Desktop.
function JumpDefinitionWithSetTagStack() abort
let l:old_location = [bufnr('%'), line('.'), col('.'), 0]
let l:tagname = expand('<cword>')
let l:winid = win_getid()
call settagstack(l:winid, {'items': [{'from': l:old_location, 'tagname': l:tagname}]}, 'a')
call settagstack(l:winid, {'curidx': len(gettagstack(l:winid)['items']) + 1})
call CocAction('jumpDefinition')
endfunction
nnoremap <Plug>(jump-definition-with-settagstack) :<C-u>call JumpDefinitionWithSetTagStack()<CR>
nmap <C-]> <Plug>(jump-definition-with-settagstack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment