Skip to content

Commit

Permalink
Add a check to use the new error message returned and also handle nil…
Browse files Browse the repository at this point in the history
… client id for LSP
  • Loading branch information
chipsenkbeil committed Jul 7, 2024
1 parent 823267c commit cfd56ab
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/distant-core/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ function M:connect_lsp_clients(opts)
log.fmt_trace('File %s of type %s applies to %s', path, buf_ft, label)

-- Start the client if it doesn't exist
--
-- Details: Start LSP server using the provided configuration,
-- replacing the command with the distant-wrapped verison and
-- shadowing the on_exit command if provided
if self.__state.lsp.clients[label] == nil then
-- Wrap the exit so we can clear our id tracker
local on_exit = function(code, signal, client_id)
Expand All @@ -208,11 +212,13 @@ function M:connect_lsp_clients(opts)
root_dir = root_dir,
})

-- Start LSP server using the provided configuration, replacing the
-- command with the distant-wrapped verison and shadowing the
-- on_exit command if provided
-- Attempt to start the client, failing immediately if
-- we are unable to start the client or get an explicit
-- error message to report
log.fmt_debug('Starting LSP %s: %s', label, config)
local id = vim.lsp.start_client(config)
local id, err = vim.lsp.start_client(config)
assert(id, 'Unable to start LSP client' .. (err and (': ' .. err) or ''))

self.__state.lsp.clients[label] = id
end

Expand Down

0 comments on commit cfd56ab

Please sign in to comment.