Use one LSP connection per project

This commit is contained in:
w0rp
2018-08-24 13:16:58 +01:00
parent 9d7c48038c
commit c4eca7c417
13 changed files with 286 additions and 467 deletions

View File

@@ -9,6 +9,7 @@ Before:
let g:preview_called = 0
let g:item_list = []
let g:capability_checked = ''
let g:conn_id = v:null
let g:WaitCallback = v:null
runtime autoload/ale/linter.vim
@@ -17,19 +18,18 @@ Before:
runtime autoload/ale/preview.vim
function! ale#lsp_linter#StartLSP(buffer, linter) abort
let l:conn = ale#lsp#NewConnection({})
let l:conn.id = 347
let l:conn.open_documents = {a:buffer : -1}
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
return {
\ 'buffer': a:buffer,
\ 'connection_id': 347,
\ 'connection_id': g:conn_id,
\ 'project_root': '/foo/bar',
\ 'language_id': 'python',
\}
endfunction
function! ale#lsp#WaitForCapability(conn_id, project_root, capability, callback) abort
function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort
let g:capability_checked = a:capability
let g:WaitCallback = a:callback
endfunction
@@ -38,7 +38,7 @@ Before:
let g:Callback = a:callback
endfunction
function! ale#lsp#Send(conn_id, message, root) abort
function! ale#lsp#Send(conn_id, message) abort
call add(g:message_list, a:message)
return 42
@@ -54,7 +54,10 @@ Before:
endfunction
After:
call ale#lsp#RemoveConnectionWithID(347)
if g:conn_id isnot v:null
call ale#lsp#RemoveConnectionWithID(g:conn_id)
endif
call ale#references#SetMap({})
call ale#test#RestoreDirectory()
call ale#linter#Reset()
@@ -62,6 +65,7 @@ After:
unlet! g:capability_checked
unlet! g:WaitCallback
unlet! g:old_filename
unlet! g:conn_id
unlet! g:Callback
unlet! g:message_list
unlet! g:expr_list
@@ -168,7 +172,7 @@ Execute(tsserver reference requests should be sent):
AssertEqual type(function('type')), type(g:WaitCallback)
AssertEqual 'references', g:capability_checked
call call(g:WaitCallback, [347, '/foo/bar'])
call call(g:WaitCallback, [g:conn_id, '/foo/bar'])
AssertEqual
\ 'function(''ale#references#HandleTSServerResponse'')',
@@ -249,7 +253,7 @@ Execute(LSP reference requests should be sent):
AssertEqual type(function('type')), type(g:WaitCallback)
AssertEqual 'references', g:capability_checked
call call(g:WaitCallback, [347, '/foo/bar'])
call call(g:WaitCallback, [g:conn_id, '/foo/bar'])
AssertEqual
\ 'function(''ale#references#HandleLSPResponse'')',