mirror of
https://github.com/dense-analysis/ale.git
synced 2026-03-07 07:32:01 +08:00
#2132 Use an on-init callback for all LSP logic
This commit is contained in:
@@ -57,7 +57,13 @@ function! ale#symbol#HandleLSPResponse(conn_id, response) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:OnReady(linter, lsp_details, query, options, ...) abort
|
||||
function! s:OnReady(query, options, linter, lsp_details) abort
|
||||
let l:id = a:lsp_details.connection_id
|
||||
|
||||
if !ale#lsp#HasCapability(l:id, 'symbol_search')
|
||||
return
|
||||
endif
|
||||
|
||||
let l:buffer = a:lsp_details.buffer
|
||||
|
||||
" If we already made a request, stop here.
|
||||
@@ -65,8 +71,6 @@ function! s:OnReady(linter, lsp_details, query, options, ...) abort
|
||||
return
|
||||
endif
|
||||
|
||||
let l:id = a:lsp_details.connection_id
|
||||
|
||||
let l:Callback = function('ale#symbol#HandleLSPResponse')
|
||||
call ale#lsp#RegisterCallback(l:id, l:Callback)
|
||||
|
||||
@@ -80,18 +84,6 @@ function! s:OnReady(linter, lsp_details, query, options, ...) abort
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! s:Search(linter, buffer, query, options) abort
|
||||
let l:lsp_details = ale#lsp_linter#StartLSP(a:buffer, a:linter)
|
||||
|
||||
if !empty(l:lsp_details)
|
||||
call ale#lsp#WaitForCapability(
|
||||
\ l:lsp_details.connection_id,
|
||||
\ 'symbol_search',
|
||||
\ function('s:OnReady', [a:linter, l:lsp_details, a:query, a:options]),
|
||||
\)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#symbol#Search(args) abort
|
||||
let [l:opts, l:query] = ale#args#Parse(['relative'], a:args)
|
||||
|
||||
@@ -108,10 +100,11 @@ function! ale#symbol#Search(args) abort
|
||||
|
||||
" Set a flag so we only make one request.
|
||||
call setbufvar(l:buffer, 'ale_symbol_request_made', 0)
|
||||
let l:Callback = function('s:OnReady', [l:query, l:options])
|
||||
|
||||
for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
||||
if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver'
|
||||
call s:Search(l:linter, l:buffer, l:query, l:options)
|
||||
call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user