diff options
author | Reed Riley <john.reed.riley@gmail.com> | 2019-04-19 17:09:51 -0400 |
---|---|---|
committer | Reed Riley <john.reed.riley@gmail.com> | 2019-04-19 23:10:55 -0400 |
commit | c36f3e78e47ae3b83eba6b2ad7139ed4d8f7ed9b (patch) | |
tree | f8d329ff8ea20a7b926f5e72b3e7832db858bbca /autoload | |
parent | fcc2c3ba71afa2a7965f3c1e9ec8c03381178180 (diff) | |
download | ale-c36f3e78e47ae3b83eba6b2ad7139ed4d8f7ed9b.zip |
Add support for Vim's tagstack to ALEGoToDefinition
fixes 1236
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/definition.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/autoload/ale/definition.vim b/autoload/ale/definition.vim index 521f0b45..6b5dbfe0 100644 --- a/autoload/ale/definition.vim +++ b/autoload/ale/definition.vim @@ -3,6 +3,9 @@ let s:go_to_definition_map = {} +" Enable automatic updates of the tagstack +let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1) + " Used to get the definition map in tests. function! ale#definition#GetMap() abort return deepcopy(s:go_to_definition_map) @@ -17,6 +20,18 @@ function! ale#definition#ClearLSPData() abort let s:go_to_definition_map = {} endfunction +function! ale#definition#UpdateTagStack() abort + let l:should_update_tagstack = exists('*gettagstack') && exists('*settagstack') && g:ale_update_tagstack + + if l:should_update_tagstack + let l:from = [bufnr('%'), line('.'), col('.'), 0] + let l:tagname = expand('<cword>') + let l:winid = win_getid() + call settagstack(l:winid, {'items': [{'from': l:from, 'tagname': l:tagname}]}, 'a') + call settagstack(l:winid, {'curidx': len(gettagstack(l:winid)['items']) + 1}) + endif +endfunction + function! ale#definition#HandleTSServerResponse(conn_id, response) abort if get(a:response, 'command', '') is# 'definition' \&& has_key(s:go_to_definition_map, a:response.request_seq) @@ -27,6 +42,7 @@ function! ale#definition#HandleTSServerResponse(conn_id, response) abort let l:line = a:response.body[0].start.line let l:column = a:response.body[0].start.offset + call ale#definition#UpdateTagStack() call ale#util#Open(l:filename, l:line, l:column, l:options) endif endif @@ -51,6 +67,7 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort let l:line = l:item.range.start.line + 1 let l:column = l:item.range.start.character + 1 + call ale#definition#UpdateTagStack() call ale#util#Open(l:filename, l:line, l:column, l:options) break endfor |