Closes #3019 - Implement default navigation

Default navigation for commands that jump to new locations has been
implemented with the `ale_default_navigation` variable, and all commands
that jump to locations now support `-tab`, `-split`, or `-vsplit`
arguments for overriding the default navigation behavior.
This commit is contained in:
w0rp
2020-04-15 16:50:13 +01:00
parent bbe5153fcb
commit 82f734a7c2
9 changed files with 278 additions and 113 deletions
+34 -4
View File
@@ -2,6 +2,8 @@ Before:
call ale#test#SetDirectory('/testplugin/test')
call ale#test#SetFilename('dummy.txt')
Save g:ale_default_navigation
let g:old_filename = expand('%:p')
let g:Callback = ''
let g:message_list = []
@@ -9,6 +11,7 @@ Before:
let g:capability_checked = ''
let g:conn_id = v:null
let g:InitCallback = v:null
let g:ale_default_navigation = 'buffer'
runtime autoload/ale/linter.vim
runtime autoload/ale/lsp_linter.vim
@@ -54,6 +57,8 @@ Before:
endfunction
After:
Restore
if g:conn_id isnot v:null
call ale#lsp#RemoveConnectionWithID(g:conn_id)
endif
@@ -164,7 +169,7 @@ Execute(Other files should be jumped to for definition responses in tabs too):
AssertEqual {}, ale#definition#GetMap()
Execute(Other files should be jumped to for definition responses in splits too):
call ale#definition#SetMap({3: {'open_in': 'horizontal-split'}})
call ale#definition#SetMap({3: {'open_in': 'split'}})
call ale#definition#HandleTSServerResponse(
\ 1,
\ {
@@ -189,7 +194,7 @@ Execute(Other files should be jumped to for definition responses in splits too):
AssertEqual {}, ale#definition#GetMap()
Execute(Other files should be jumped to for definition responses in vsplits too):
call ale#definition#SetMap({3: {'open_in': 'vertical-split'}})
call ale#definition#SetMap({3: {'open_in': 'vsplit'}})
call ale#definition#HandleTSServerResponse(
\ 1,
\ {
@@ -241,7 +246,32 @@ Execute(tsserver tab definition requests should be sent):
runtime ale_linters/typescript/tsserver.vim
call setpos('.', [bufnr(''), 2, 5, 0])
ALEGoToDefinitionInTab
ALEGoToDefinition -tab
" We shouldn't register the callback yet.
AssertEqual '''''', string(g:Callback)
AssertEqual type(function('type')), type(g:InitCallback)
call g:InitCallback()
AssertEqual 'definition', g:capability_checked
AssertEqual
\ 'function(''ale#definition#HandleTSServerResponse'')',
\ string(g:Callback)
AssertEqual
\ [
\ ale#lsp#tsserver_message#Change(bufnr('')),
\ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
\ ],
\ g:message_list
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
Execute(The default navigation type should be used):
runtime ale_linters/typescript/tsserver.vim
call setpos('.', [bufnr(''), 2, 5, 0])
let g:ale_default_navigation = 'tab'
ALEGoToDefinition
" We shouldn't register the callback yet.
AssertEqual '''''', string(g:Callback)
@@ -448,7 +478,7 @@ Execute(LSP tab definition requests should be sent):
let b:ale_linters = ['pyls']
call setpos('.', [bufnr(''), 1, 5, 0])
ALEGoToDefinitionInTab
ALEGoToDefinition -tab
" We shouldn't register the callback yet.
AssertEqual '''''', string(g:Callback)