mirror of
https://github.com/dense-analysis/ale
synced 2024-12-22 14:13:12 +00:00
Close #830 - Implement LSP connections via TCP sockets
This commit is contained in:
parent
5aba55bb86
commit
e46474ac0a
@ -3,7 +3,7 @@
|
||||
|
||||
" A List of connections, used for tracking servers which have been connected
|
||||
" to, and programs which are run.
|
||||
let s:connections = []
|
||||
let s:connections = get(s:, 'connections', [])
|
||||
let g:ale_lsp_next_message_id = 1
|
||||
|
||||
" Exposed only so tests can get at it.
|
||||
@ -36,7 +36,7 @@ endfunction
|
||||
|
||||
function! s:FindConnection(key, value) abort
|
||||
for l:conn in s:connections
|
||||
if has_key(l:conn, a:key) && get(l:conn, a:key) == a:value
|
||||
if has_key(l:conn, a:key) && get(l:conn, a:key) is# a:value
|
||||
return l:conn
|
||||
endif
|
||||
endfor
|
||||
@ -319,13 +319,13 @@ function! ale#lsp#ConnectToAddress(address, project_root, callback, initializati
|
||||
let l:conn = !empty(l:conn) ? l:conn : ale#lsp#NewConnection(a:initialization_options)
|
||||
|
||||
if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id)
|
||||
let l:conn.channnel_id = ale#socket#Open(a:address, {
|
||||
let l:conn.channel_id = ale#socket#Open(a:address, {
|
||||
\ 'callback': function('s:HandleChannelMessage'),
|
||||
\})
|
||||
endif
|
||||
|
||||
if l:conn.channnel_id < 0
|
||||
return 0
|
||||
if l:conn.channel_id < 0
|
||||
return ''
|
||||
endif
|
||||
|
||||
let l:conn.id = a:address
|
||||
@ -333,7 +333,7 @@ function! ale#lsp#ConnectToAddress(address, project_root, callback, initializati
|
||||
call uniq(sort(add(l:conn.callback_list, a:callback)))
|
||||
call ale#lsp#RegisterProject(l:conn, a:project_root)
|
||||
|
||||
return 1
|
||||
return a:address
|
||||
endfunction
|
||||
|
||||
" Stop all LSP connections, closing all jobs and channels, and removing any
|
||||
|
@ -166,7 +166,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort
|
||||
|
||||
let l:language_id = ale#util#GetFunction(a:linter.language_callback)(a:buffer)
|
||||
|
||||
if !l:conn_id
|
||||
if empty(l:conn_id)
|
||||
if g:ale_history_enabled && !empty(l:command)
|
||||
call ale#history#Add(a:buffer, 'failed', l:conn_id, l:command)
|
||||
endif
|
||||
|
17
doc/ale.txt
17
doc/ale.txt
@ -2371,8 +2371,16 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()*
|
||||
|
||||
When this argument is set to `'stdio'`, then the
|
||||
linter will be defined as an LSP linter which keeps a
|
||||
process for a language server runnning, and
|
||||
process for a language server running, and
|
||||
communicates with it directly via a |channel|.
|
||||
`executable` or `executable_callback` must be set,
|
||||
and `command` or `command_callback` must be set.
|
||||
|
||||
When this argument is set to `'socket'`, then the
|
||||
linter will be defined as an LSP linter via a TCP
|
||||
socket connection. `address_callback` must be set
|
||||
with a callback returning an address to connect to.
|
||||
ALE will not start a server automatically.
|
||||
|
||||
When this argument is not empty, only one of either
|
||||
`language` or `language_callback` must be defined,
|
||||
@ -2388,6 +2396,13 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()*
|
||||
`initialization_options_callback` may be defined to
|
||||
pass initialization options to the LSP.
|
||||
|
||||
`address_callback` A |String| or |Funcref| for a callback function
|
||||
accepting a buffer number. A |String| should be
|
||||
returned with an address to connect to.
|
||||
|
||||
This argument must only be set if the `lsp` argument
|
||||
is set to `'socket'`.
|
||||
|
||||
`project_root_callback` A |String| or |Funcref| for a callback function
|
||||
accepting a buffer number. A |String| should be
|
||||
returned representing the path to the project for the
|
||||
|
Loading…
Reference in New Issue
Block a user