Updated plugins

This commit is contained in:
Amir Salihefendic
2019-03-08 08:04:56 -03:00
parent 1d42b63013
commit f50b2142bc
356 changed files with 6183 additions and 3837 deletions

View File

@@ -17,7 +17,7 @@ endfunction
function! ale#references#HandleTSServerResponse(conn_id, response) abort
if get(a:response, 'command', '') is# 'references'
\&& has_key(s:references_map, a:response.request_seq)
call remove(s:references_map, a:response.request_seq)
let l:options = remove(s:references_map, a:response.request_seq)
if get(a:response, 'success', v:false) is v:true
let l:item_list = []
@@ -34,7 +34,7 @@ function! ale#references#HandleTSServerResponse(conn_id, response) abort
if empty(l:item_list)
call ale#util#Execute('echom ''No references found.''')
else
call ale#preview#ShowSelection(l:item_list)
call ale#preview#ShowSelection(l:item_list, l:options)
endif
endif
endif
@@ -43,7 +43,7 @@ endfunction
function! ale#references#HandleLSPResponse(conn_id, response) abort
if has_key(a:response, 'id')
\&& has_key(s:references_map, a:response.id)
call remove(s:references_map, a:response.id)
let l:options = remove(s:references_map, a:response.id)
" The result can be a Dictionary item, a List of the same, or null.
let l:result = get(a:response, 'result', [])
@@ -60,15 +60,20 @@ function! ale#references#HandleLSPResponse(conn_id, response) abort
if empty(l:item_list)
call ale#util#Execute('echom ''No references found.''')
else
call ale#preview#ShowSelection(l:item_list)
call ale#preview#ShowSelection(l:item_list, l:options)
endif
endif
endfunction
function! s:OnReady(linter, lsp_details, line, column, ...) abort
let l:buffer = a:lsp_details.buffer
function! s:OnReady(line, column, options, linter, lsp_details) abort
let l:id = a:lsp_details.connection_id
if !ale#lsp#HasCapability(l:id, 'references')
return
endif
let l:buffer = a:lsp_details.buffer
let l:Callback = a:linter.lsp is# 'tsserver'
\ ? function('ale#references#HandleTSServerResponse')
\ : function('ale#references#HandleLSPResponse')
@@ -91,34 +96,30 @@ function! s:OnReady(linter, lsp_details, line, column, ...) abort
let l:request_id = ale#lsp#Send(l:id, l:message)
let s:references_map[l:request_id] = {}
let s:references_map[l:request_id] = {
\ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0
\}
endfunction
function! s:FindReferences(linter) abort
function! ale#references#Find(...) abort
let l:options = {}
if len(a:000) > 0
for l:option in a:000
if l:option is? '-relative'
let l:options.use_relative_paths = 1
endif
endfor
endif
let l:buffer = bufnr('')
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
let l:column = min([l:column, len(getline(l:line))])
let l:Callback = function('s:OnReady', [l:line, l:column, l:options])
if a:linter.lsp isnot# 'tsserver'
let l:column = min([l:column, len(getline(l:line))])
endif
let l:lsp_details = ale#lsp_linter#StartLSP(l:buffer, a:linter)
if empty(l:lsp_details)
return 0
endif
let l:id = l:lsp_details.connection_id
call ale#lsp#WaitForCapability(l:id, 'references', function('s:OnReady', [
\ a:linter, l:lsp_details, l:line, l:column
\]))
endfunction
function! ale#references#Find() abort
for l:linter in ale#linter#Get(&filetype)
if !empty(l:linter.lsp)
call s:FindReferences(l:linter)
call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
endif
endfor
endfunction