2017-11-21 00:21:45 +00:00
|
|
|
Before:
|
|
|
|
call ale#test#SetDirectory('/testplugin/test')
|
|
|
|
call ale#test#SetFilename('dummy.txt')
|
|
|
|
|
2020-04-15 15:50:13 +00:00
|
|
|
Save g:ale_default_navigation
|
|
|
|
|
2017-11-21 00:21:45 +00:00
|
|
|
let g:old_filename = expand('%:p')
|
2018-07-22 18:04:45 +00:00
|
|
|
let g:Callback = ''
|
2017-11-26 22:27:08 +00:00
|
|
|
let g:message_list = []
|
2017-11-21 00:21:45 +00:00
|
|
|
let g:expr_list = []
|
2018-07-22 18:04:45 +00:00
|
|
|
let g:capability_checked = ''
|
2018-08-24 12:16:58 +00:00
|
|
|
let g:conn_id = v:null
|
2019-02-13 00:31:33 +00:00
|
|
|
let g:InitCallback = v:null
|
2020-04-15 15:50:13 +00:00
|
|
|
let g:ale_default_navigation = 'buffer'
|
2017-11-21 00:21:45 +00:00
|
|
|
|
|
|
|
runtime autoload/ale/linter.vim
|
2019-02-15 08:54:53 +00:00
|
|
|
runtime autoload/ale/lsp_linter.vim
|
2017-11-21 00:21:45 +00:00
|
|
|
runtime autoload/ale/lsp.vim
|
2018-04-22 14:53:01 +00:00
|
|
|
runtime autoload/ale/util.vim
|
2017-11-21 00:21:45 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
|
2018-08-24 12:16:58 +00:00
|
|
|
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
|
|
|
|
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
|
2019-02-15 08:54:53 +00:00
|
|
|
|
|
|
|
if a:linter.lsp is# 'tsserver'
|
|
|
|
call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
|
|
|
|
endif
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
let l:details = {
|
2019-02-15 08:54:53 +00:00
|
|
|
\ 'command': 'foobar',
|
2018-06-15 08:53:13 +00:00
|
|
|
\ 'buffer': a:buffer,
|
2018-08-24 12:16:58 +00:00
|
|
|
\ 'connection_id': g:conn_id,
|
2017-11-21 00:21:45 +00:00
|
|
|
\ 'project_root': '/foo/bar',
|
|
|
|
\}
|
2019-02-13 00:31:33 +00:00
|
|
|
|
2019-02-15 08:54:53 +00:00
|
|
|
let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
|
2017-11-21 00:21:45 +00:00
|
|
|
endfunction
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
function! ale#lsp#HasCapability(conn_id, capability) abort
|
2018-07-22 18:04:45 +00:00
|
|
|
let g:capability_checked = a:capability
|
2019-02-13 00:31:33 +00:00
|
|
|
|
|
|
|
return 1
|
2018-07-22 18:04:45 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#lsp#RegisterCallback(conn_id, callback) abort
|
|
|
|
let g:Callback = a:callback
|
|
|
|
endfunction
|
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
function! ale#lsp#Send(conn_id, message) abort
|
2017-11-26 22:27:08 +00:00
|
|
|
call add(g:message_list, a:message)
|
2017-11-21 00:21:45 +00:00
|
|
|
|
|
|
|
return 42
|
|
|
|
endfunction
|
|
|
|
|
2018-04-22 14:53:01 +00:00
|
|
|
function! ale#util#Execute(expr) abort
|
2017-11-21 00:21:45 +00:00
|
|
|
call add(g:expr_list, a:expr)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
After:
|
2020-04-15 15:50:13 +00:00
|
|
|
Restore
|
|
|
|
|
2018-08-24 12:16:58 +00:00
|
|
|
if g:conn_id isnot v:null
|
|
|
|
call ale#lsp#RemoveConnectionWithID(g:conn_id)
|
|
|
|
endif
|
|
|
|
|
2018-04-22 14:53:01 +00:00
|
|
|
call ale#definition#SetMap({})
|
2017-11-21 00:21:45 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
2018-07-22 18:04:45 +00:00
|
|
|
unlet! g:capability_checked
|
2019-02-13 00:31:33 +00:00
|
|
|
unlet! g:InitCallback
|
2017-11-21 00:21:45 +00:00
|
|
|
unlet! g:old_filename
|
2018-08-24 12:16:58 +00:00
|
|
|
unlet! g:conn_id
|
2017-11-21 00:21:45 +00:00
|
|
|
unlet! g:Callback
|
2017-11-26 22:27:08 +00:00
|
|
|
unlet! g:message_list
|
2017-11-21 00:21:45 +00:00
|
|
|
unlet! g:expr_list
|
2017-11-26 22:27:08 +00:00
|
|
|
unlet! b:ale_linters
|
2017-11-21 00:21:45 +00:00
|
|
|
|
2018-07-06 00:00:30 +00:00
|
|
|
runtime autoload/ale/lsp_linter.vim
|
2017-11-21 00:21:45 +00:00
|
|
|
runtime autoload/ale/lsp.vim
|
2018-04-22 14:53:01 +00:00
|
|
|
runtime autoload/ale/util.vim
|
2017-11-21 00:21:45 +00:00
|
|
|
|
|
|
|
Execute(Other messages for the tsserver handler should be ignored):
|
|
|
|
call ale#definition#HandleTSServerResponse(1, {'command': 'foo'})
|
|
|
|
|
2019-04-19 21:09:51 +00:00
|
|
|
Execute(Tagstack should be incremented if supported):
|
|
|
|
if exists('*gettagstack') && exists('*settagstack')
|
|
|
|
let original_stack_depth = gettagstack().length
|
|
|
|
endif
|
|
|
|
call ale#definition#UpdateTagStack()
|
|
|
|
if exists('*gettagstack') && exists('*settagstack')
|
|
|
|
AssertEqual original_stack_depth + 1, gettagstack().length
|
|
|
|
endif
|
|
|
|
|
2017-11-21 00:21:45 +00:00
|
|
|
Execute(Failed definition responses should be handled correctly):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2017-11-21 00:21:45 +00:00
|
|
|
call ale#definition#HandleTSServerResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {'command': 'definition', 'request_seq': 3}
|
|
|
|
\)
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2018-06-01 13:15:32 +00:00
|
|
|
Execute(Failed definition responses with no files should be handled correctly):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2018-06-01 13:15:32 +00:00
|
|
|
call ale#definition#HandleTSServerResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'command': 'definition',
|
|
|
|
\ 'request_seq': 3,
|
|
|
|
\ 'success': v:true,
|
|
|
|
\ 'body': [],
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2017-11-21 00:21:45 +00:00
|
|
|
Given typescript(Some typescript file):
|
|
|
|
foo
|
|
|
|
somelongerline
|
|
|
|
bazxyzxyzxyz
|
|
|
|
|
|
|
|
Execute(Other files should be jumped to for definition responses):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2017-11-21 00:21:45 +00:00
|
|
|
call ale#definition#HandleTSServerResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'command': 'definition',
|
|
|
|
\ 'request_seq': 3,
|
|
|
|
\ 'success': v:true,
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
|
2017-11-21 00:21:45 +00:00
|
|
|
\ 'start': {'line': 3, 'offset': 7},
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2018-08-07 20:51:23 +00:00
|
|
|
\ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-21 00:21:45 +00:00
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
|
|
|
AssertEqual [3, 7], getpos('.')[1:2]
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
|
|
|
Execute(Other files should be jumped to for definition responses in tabs too):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'tab'}})
|
2017-11-21 00:21:45 +00:00
|
|
|
call ale#definition#HandleTSServerResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'command': 'definition',
|
|
|
|
\ 'request_seq': 3,
|
|
|
|
\ 'success': v:true,
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
|
2017-11-21 00:21:45 +00:00
|
|
|
\ 'start': {'line': 3, 'offset': 7},
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2018-08-07 20:51:23 +00:00
|
|
|
\ 'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-21 00:21:45 +00:00
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
|
|
|
AssertEqual [3, 7], getpos('.')[1:2]
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2018-12-12 19:35:57 +00:00
|
|
|
Execute(Other files should be jumped to for definition responses in splits too):
|
2020-04-15 15:50:13 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'split'}})
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#HandleTSServerResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'command': 'definition',
|
|
|
|
\ 'request_seq': 3,
|
|
|
|
\ 'success': v:true,
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
|
|
|
|
\ 'start': {'line': 3, 'offset': 7},
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 'split +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
|
|
|
AssertEqual [3, 7], getpos('.')[1:2]
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
|
|
|
Execute(Other files should be jumped to for definition responses in vsplits too):
|
2020-04-15 15:50:13 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'vsplit'}})
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#HandleTSServerResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'command': 'definition',
|
|
|
|
\ 'request_seq': 3,
|
|
|
|
\ 'success': v:true,
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
|
|
|
\ 'file': ale#path#Simplify(g:dir . '/completion_dummy_file'),
|
|
|
|
\ 'start': {'line': 3, 'offset': 7},
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 'vsplit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
|
|
|
AssertEqual [3, 7], getpos('.')[1:2]
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2019-01-21 23:06:28 +00:00
|
|
|
Execute(tsserver definition requests should be sent):
|
2017-11-21 00:21:45 +00:00
|
|
|
runtime ale_linters/typescript/tsserver.vim
|
|
|
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
|
|
|
|
|
|
|
ALEGoToDefinition
|
|
|
|
|
2018-07-22 18:04:45 +00:00
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
2018-07-22 18:04:45 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual 'definition', g:capability_checked
|
2017-11-21 00:21:45 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
AssertEqual
|
2019-02-15 08:54:53 +00:00
|
|
|
\ [
|
|
|
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
|
|
|
\ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
|
|
|
\ ],
|
2017-11-26 22:27:08 +00:00
|
|
|
\ g:message_list
|
2018-12-12 19:35:57 +00:00
|
|
|
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
2017-11-21 00:21:45 +00:00
|
|
|
|
2021-02-20 16:09:28 +00:00
|
|
|
Execute(tsserver type definition requests should be sent):
|
|
|
|
runtime ale_linters/typescript/tsserver.vim
|
|
|
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
|
|
|
|
|
|
|
ALEGoToTypeDefinition
|
|
|
|
|
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
|
|
|
|
|
|
|
AssertEqual 'typeDefinition', g:capability_checked
|
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
|
|
|
\ [0, 'ts@typeDefinition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
|
|
|
\ ],
|
|
|
|
\ g:message_list
|
|
|
|
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
|
|
|
|
2019-01-21 23:06:28 +00:00
|
|
|
Execute(tsserver tab definition requests should be sent):
|
2017-11-21 00:21:45 +00:00
|
|
|
runtime ale_linters/typescript/tsserver.vim
|
|
|
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
|
|
|
|
2020-04-15 15:50:13 +00:00
|
|
|
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
|
2017-11-21 00:21:45 +00:00
|
|
|
|
2018-07-22 18:04:45 +00:00
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
2018-07-22 18:04:45 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual 'definition', g:capability_checked
|
2017-11-21 00:21:45 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
AssertEqual
|
2019-02-15 08:54:53 +00:00
|
|
|
\ [
|
|
|
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
|
|
|
\ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
|
|
|
\ ],
|
2017-11-26 22:27:08 +00:00
|
|
|
\ g:message_list
|
2018-12-12 19:35:57 +00:00
|
|
|
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
2017-11-26 22:27:08 +00:00
|
|
|
|
|
|
|
Given python(Some Python file):
|
|
|
|
foo
|
|
|
|
somelongerline
|
|
|
|
bazxyzxyzxyz
|
|
|
|
|
|
|
|
Execute(Other files should be jumped to for LSP definition responses):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2017-11-26 22:27:08 +00:00
|
|
|
call ale#definition#HandleLSPResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'id': 3,
|
|
|
|
\ 'result': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ 'range': {
|
|
|
|
\ 'start': {'line': 2, 'character': 7},
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2018-08-07 20:51:23 +00:00
|
|
|
\ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
2018-08-27 12:52:49 +00:00
|
|
|
AssertEqual [3, 8], getpos('.')[1:2]
|
2017-11-26 22:27:08 +00:00
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2021-03-14 21:10:05 +00:00
|
|
|
Execute(Newer LocationLink items should be supported):
|
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
|
|
|
call ale#definition#HandleLSPResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'id': 3,
|
|
|
|
\ 'result': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'targetUri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2021-03-14 21:10:05 +00:00
|
|
|
\ 'targetRange': {
|
|
|
|
\ 'start': {'line': 2, 'character': 7},
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
|
|
|
AssertEqual [3, 8], getpos('.')[1:2]
|
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2018-06-21 20:20:54 +00:00
|
|
|
Execute(Locations inside the same file should be jumped to without using :edit):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2018-06-21 20:20:54 +00:00
|
|
|
call ale#definition#HandleLSPResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'id': 3,
|
|
|
|
\ 'result': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(expand('%:p'))),
|
2018-06-21 20:20:54 +00:00
|
|
|
\ 'range': {
|
|
|
|
\ 'start': {'line': 2, 'character': 7},
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
2018-08-27 12:52:49 +00:00
|
|
|
AssertEqual [3, 8], getpos('.')[1:2]
|
2018-06-21 20:20:54 +00:00
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
2017-11-26 22:27:08 +00:00
|
|
|
Execute(Other files should be jumped to in tabs for LSP definition responses):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'tab'}})
|
2017-11-26 22:27:08 +00:00
|
|
|
call ale#definition#HandleLSPResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'id': 3,
|
|
|
|
\ 'result': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ 'range': {
|
|
|
|
\ 'start': {'line': 2, 'character': 7},
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2018-08-07 20:51:23 +00:00
|
|
|
\ 'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
2018-08-27 12:52:49 +00:00
|
|
|
AssertEqual [3, 8], getpos('.')[1:2]
|
2017-11-26 22:27:08 +00:00
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
|
|
|
Execute(Definition responses with lists should be handled):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2017-11-26 22:27:08 +00:00
|
|
|
call ale#definition#HandleLSPResponse(
|
|
|
|
\ 1,
|
|
|
|
\ {
|
|
|
|
\ 'id': 3,
|
|
|
|
\ 'result': [
|
|
|
|
\ {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ 'range': {
|
|
|
|
\ 'start': {'line': 2, 'character': 7},
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ 'range': {
|
|
|
|
\ 'start': {'line': 20, 'character': 3},
|
|
|
|
\ },
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ }
|
|
|
|
\)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
2018-08-07 20:51:23 +00:00
|
|
|
\ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ ],
|
|
|
|
\ g:expr_list
|
2018-08-27 12:52:49 +00:00
|
|
|
AssertEqual [3, 8], getpos('.')[1:2]
|
2017-11-26 22:27:08 +00:00
|
|
|
AssertEqual {}, ale#definition#GetMap()
|
|
|
|
|
|
|
|
Execute(Definition responses with null response should be handled):
|
2018-12-12 19:35:57 +00:00
|
|
|
call ale#definition#SetMap({3: {'open_in': 'current-buffer'}})
|
2017-11-26 22:27:08 +00:00
|
|
|
call ale#definition#HandleLSPResponse(1, {'id': 3, 'result': v:null})
|
|
|
|
|
|
|
|
AssertEqual [], g:expr_list
|
|
|
|
|
2019-01-21 23:06:28 +00:00
|
|
|
Execute(LSP definition requests should be sent):
|
2021-07-09 13:40:31 +00:00
|
|
|
runtime ale_linters/python/pylsp.vim
|
|
|
|
let b:ale_linters = ['pylsp']
|
2017-11-26 22:27:08 +00:00
|
|
|
call setpos('.', [bufnr(''), 1, 5, 0])
|
|
|
|
|
|
|
|
ALEGoToDefinition
|
|
|
|
|
2018-07-22 18:04:45 +00:00
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
2018-07-22 18:04:45 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual 'definition', g:capability_checked
|
2017-11-26 22:27:08 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleLSPResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ [1, 'textDocument/didChange', {
|
|
|
|
\ 'textDocument': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(expand('%:p')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ 'version': g:ale_lsp_next_version_id - 1,
|
|
|
|
\ },
|
|
|
|
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
|
|
|
|
\ }],
|
|
|
|
\ [0, 'textDocument/definition', {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 0, 'character': 2},
|
2017-11-26 22:27:08 +00:00
|
|
|
\ }],
|
|
|
|
\ ],
|
|
|
|
\ g:message_list
|
|
|
|
|
2018-12-12 19:35:57 +00:00
|
|
|
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
2017-11-26 22:27:08 +00:00
|
|
|
|
2019-01-21 23:06:28 +00:00
|
|
|
Execute(LSP type definition requests should be sent):
|
2021-07-09 13:40:31 +00:00
|
|
|
runtime ale_linters/python/pylsp.vim
|
|
|
|
let b:ale_linters = ['pylsp']
|
2019-01-21 23:06:28 +00:00
|
|
|
call setpos('.', [bufnr(''), 1, 5, 0])
|
|
|
|
|
|
|
|
ALEGoToTypeDefinition
|
|
|
|
|
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
2019-01-21 23:06:28 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual 'typeDefinition', g:capability_checked
|
2019-01-21 23:06:28 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleLSPResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ [1, 'textDocument/didChange', {
|
|
|
|
\ 'textDocument': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(expand('%:p')),
|
2019-01-21 23:06:28 +00:00
|
|
|
\ 'version': g:ale_lsp_next_version_id - 1,
|
|
|
|
\ },
|
|
|
|
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
|
|
|
|
\ }],
|
|
|
|
\ [0, 'textDocument/typeDefinition', {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
|
2019-01-21 23:06:28 +00:00
|
|
|
\ 'position': {'line': 0, 'character': 2},
|
|
|
|
\ }],
|
|
|
|
\ ],
|
|
|
|
\ g:message_list
|
|
|
|
|
|
|
|
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
|
|
|
|
|
|
|
|
Execute(LSP tab definition requests should be sent):
|
2021-07-09 13:40:31 +00:00
|
|
|
runtime ale_linters/python/pylsp.vim
|
|
|
|
let b:ale_linters = ['pylsp']
|
2017-11-26 22:27:08 +00:00
|
|
|
call setpos('.', [bufnr(''), 1, 5, 0])
|
|
|
|
|
2020-04-15 15:50:13 +00:00
|
|
|
ALEGoToDefinition -tab
|
2017-11-26 22:27:08 +00:00
|
|
|
|
2018-07-22 18:04:45 +00:00
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
2018-07-22 18:04:45 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual 'definition', g:capability_checked
|
2017-11-26 22:27:08 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleLSPResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ [1, 'textDocument/didChange', {
|
|
|
|
\ 'textDocument': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(expand('%:p')),
|
2017-11-26 22:27:08 +00:00
|
|
|
\ 'version': g:ale_lsp_next_version_id - 1,
|
|
|
|
\ },
|
|
|
|
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
|
|
|
|
\ }],
|
|
|
|
\ [0, 'textDocument/definition', {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
|
2019-01-21 14:39:43 +00:00
|
|
|
\ 'position': {'line': 0, 'character': 2},
|
2017-11-26 22:27:08 +00:00
|
|
|
\ }],
|
|
|
|
\ ],
|
|
|
|
\ g:message_list
|
|
|
|
|
2018-12-12 19:35:57 +00:00
|
|
|
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
2019-01-21 23:06:28 +00:00
|
|
|
|
|
|
|
Execute(LSP tab type definition requests should be sent):
|
2021-07-09 13:40:31 +00:00
|
|
|
runtime ale_linters/python/pylsp.vim
|
|
|
|
let b:ale_linters = ['pylsp']
|
2019-01-21 23:06:28 +00:00
|
|
|
call setpos('.', [bufnr(''), 1, 5, 0])
|
|
|
|
|
2020-08-18 22:03:43 +00:00
|
|
|
ALEGoToTypeDefinition -tab
|
2019-01-21 23:06:28 +00:00
|
|
|
|
|
|
|
" We shouldn't register the callback yet.
|
|
|
|
AssertEqual '''''', string(g:Callback)
|
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual type(function('type')), type(g:InitCallback)
|
|
|
|
call g:InitCallback()
|
2019-01-21 23:06:28 +00:00
|
|
|
|
2019-02-13 00:31:33 +00:00
|
|
|
AssertEqual 'typeDefinition', g:capability_checked
|
2019-01-21 23:06:28 +00:00
|
|
|
AssertEqual
|
|
|
|
\ 'function(''ale#definition#HandleLSPResponse'')',
|
|
|
|
\ string(g:Callback)
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ [1, 'textDocument/didChange', {
|
|
|
|
\ 'textDocument': {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'uri': ale#path#ToFileURI(expand('%:p')),
|
2019-01-21 23:06:28 +00:00
|
|
|
\ 'version': g:ale_lsp_next_version_id - 1,
|
|
|
|
\ },
|
|
|
|
\ 'contentChanges': [{'text': join(getline(1, '$'), "\n") . "\n"}]
|
|
|
|
\ }],
|
|
|
|
\ [0, 'textDocument/typeDefinition', {
|
2022-03-04 19:03:27 +00:00
|
|
|
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
|
2019-01-21 23:06:28 +00:00
|
|
|
\ 'position': {'line': 0, 'character': 2},
|
|
|
|
\ }],
|
|
|
|
\ ],
|
|
|
|
\ g:message_list
|
|
|
|
|
|
|
|
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|