mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
Add Neovim TCP connections to language servers
Support TCP connections to language servers through Neovim's built in client. In all but what is currently the nightly builds of Neovim connections via a hostname will fail, but connections via an IP address should function. We will still enable the built in Neovim client by default anyway, as LSP clients very rarely connect over TCP.
This commit is contained in:
@@ -6,6 +6,31 @@ module.start = function(config)
|
||||
config.init_options[true] = nil
|
||||
end
|
||||
|
||||
-- If configuring LSP via a socket connection, then generate the cmd
|
||||
-- using vim.lsp.rpc.connect(), as defined in Neovim documentation.
|
||||
if config.host then
|
||||
local cmd_func = vim.lsp.rpc.connect(config.host, config.port)
|
||||
config.host = nil
|
||||
config.port = nil
|
||||
|
||||
-- Wrap the cmd function so we don't throw errors back to the user
|
||||
-- if the connection to an address fails to start.
|
||||
--
|
||||
-- We will separately log in ALE that we failed to start a connection.
|
||||
--
|
||||
-- In older Neovim versions TCP connections do not function if supplied
|
||||
-- a hostname instead of an address.
|
||||
config.cmd = function(dispatch)
|
||||
local success, result = pcall(cmd_func, dispatch)
|
||||
|
||||
if success then
|
||||
return result
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
config.handlers = {
|
||||
-- Override Neovim's handling of diagnostics to run through ALE's
|
||||
-- functions so all of the functionality in ALE works.
|
||||
|
||||
Reference in New Issue
Block a user