diff options
author | w0rp <devw0rp@gmail.com> | 2017-07-30 22:18:19 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-07-30 22:18:19 +0100 |
commit | 6000d956f0a3e217c3a0563abef738616feb73e6 (patch) | |
tree | 9e2784d41ff0ff1cbeb5da0bf59acc31bd5f5a3b /autoload | |
parent | 5810d7faa0fe1fe8ae91c6bceb7dde518646a387 (diff) | |
download | ale-6000d956f0a3e217c3a0563abef738616feb73e6.zip |
When servers never send an initialize response, but instead just publish diagnostics straight away, handle that as an initialize response
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/lsp.vim | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim index eb407314..855abb11 100644 --- a/autoload/ale/lsp.vim +++ b/autoload/ale/lsp.vim @@ -156,23 +156,49 @@ function! s:FindProjectWithInitRequestID(conn, init_request_id) abort return {} endfunction +function! s:MarkProjectAsInitialized(conn, project) abort + let a:project.initialized = 1 + + " After the server starts, send messages we had queued previously. + for l:message_data in a:project.message_queue + call s:SendMessageData(a:conn, l:message_data) + endfor + + " Remove the messages now. + let a:conn.message_queue = [] +endfunction + function! s:HandleInitializeResponse(conn, response) abort let l:request_id = a:response.request_id let l:project = s:FindProjectWithInitRequestID(a:conn, l:request_id) - if empty(l:project) - return + if !empty(l:project) + call s:MarkProjectAsInitialized(a:conn, l:project) endif +endfunction - let l:project.initialized = 1 +function! ale#lsp#HandleOtherInitializeResponses(conn, response) abort + let l:uninitialized_projects = [] - " After the server starts, send messages we had queued previously. - for l:message_data in l:project.message_queue - call s:SendMessageData(a:conn, l:message_data) + for [l:key, l:value] in items(a:conn.projects) + if l:value.initialized == 0 + call add(l:uninitialized_projects, [l:key, l:value]) + endif endfor - " Remove the messages now. - let a:conn.message_queue = [] + if empty(l:uninitialized_projects) + return + endif + + if get(a:response, 'method', '') ==# 'textDocument/publishDiagnostics' + let l:filename = ale#path#FromURI(a:response.params.uri) + + for [l:dir, l:project] in l:uninitialized_projects + if l:filename[:len(l:dir) - 1] ==# l:dir + call s:MarkProjectAsInitialized(a:conn, l:project) + endif + endfor + endif endfunction function! ale#lsp#HandleMessage(conn, message) abort @@ -186,6 +212,8 @@ function! ale#lsp#HandleMessage(conn, message) abort if get(l:response, 'method', '') ==# 'initialize' call s:HandleInitializeResponse(a:conn, l:response) else + call ale#lsp#HandleOtherInitializeResponses(a:conn, l:response) + " Call all of the registered handlers with the response. for l:Callback in a:conn.callback_list call ale#util#GetFunction(l:Callback)(l:response) |