Last active
November 15, 2019 04:02
-
-
Save presuku/9d3aecf0be0d2a0c0ccc6ef11fa6b0b6 to your computer and use it in GitHub Desktop.
tagstack and LspDefinition
This file contains 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
function! s:lsp_def_add_stack() abort | |
let l:tagname = expand('<cword>') | |
let l:tagstack = gettagstack() | |
let l:bufnr = bufnr('%') | |
let l:pos = getpos('.') | |
execute("LspDefinition") | |
if l:tagstack.curidx == 1 | |
let l:action = 'r' | |
let l:length = 1 | |
let l:curidx = l:tagstack.curidx + 1 | |
else | |
let l:action = 'a' | |
let l:length = l:tagstack.length + 1 | |
let l:curidx = l:tagstack.curidx + 1 | |
endif | |
let l:pos[0] = l:bufnr | |
let l:newtag = [{'tagname': l:tagname, 'from': l:pos, 'bufnr': bufnr("%")}] | |
call settagstack(win_getid(), | |
\ {'length': l:length, 'curidx': l:curidx, 'items': l:newtag}, | |
\ l:action) | |
endfunction | |
command! LspDef call s:lsp_def_add_stack() | |
nnoremap <C-]> :<C-u>call <SID>lsp_def_add_stack()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this code is too old and a bit wrong.
And now, vim-lsp support tagstack correctlry at prabirshrestha/vim-lsp/pull/449.