Add some experimental completion code for tsserver

This commit is contained in:
w0rp
2017-07-01 01:22:03 +01:00
parent 0d8be55c51
commit 9f21e45156
5 changed files with 262 additions and 11 deletions

View File

@@ -16,6 +16,7 @@ function! s:NewConnection() abort
\ 'address': '',
\ 'executable': '',
\ 'job_id': -1,
\ 'open_documents': [],
\}
call add(s:connections, l:conn)
@@ -283,3 +284,21 @@ function! ale#lsp#SendMessageToAddress(address, message) abort
return l:id == 0 ? -1 : l:id
endfunction
function! ale#lsp#OpenTSServerDocumentIfNeeded(executable, buffer) abort
let l:opened = 0
let l:matches = filter(s:connections[:], 'v:val.executable ==# a:executable')
" Send the command for opening the document only if needed.
if !empty(l:matches) && index(l:matches[0].open_documents, a:buffer) < 0
call ale#lsp#SendMessageToProgram(
\ a:executable,
\ ale#lsp#tsserver_message#Open(a:buffer),
\)
call add(l:matches[0].open_documents, a:buffer)
let l:opened = 1
endif
return l:opened
endfunction