Skip to content

Commit 6a3134e

Browse files
committed
fix: improvements to the binary downloading timing
1 parent 6c65c53 commit 6a3134e

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

lua/copilot/client.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ local function prepare_client_config(overrides)
230230
}
231231
end
232232

233+
if not cmd then
234+
logger.error("copilot server type not supported")
235+
return
236+
end
237+
233238
local capabilities = vim.lsp.protocol.make_client_capabilities() --[[@as copilot_capabilities]]
234239
capabilities.window.showDocument.support = true
235240

@@ -348,8 +353,15 @@ function M.setup()
348353
local server_config = config.get("server") --[[@as copilot_config_server]]
349354
local node_command = config.get("copilot_node_command") --[[@as string|nil]]
350355
M.server = vim.tbl_deep_extend("force", M.server, server_config)
356+
357+
if M.server.custom_server_filepath then
358+
M.server.custom_server_filepath = vim.fs.normalize(M.server.custom_server_filepath)
359+
end
360+
351361
if M.server.type == "nodejs" then
352362
lsp_nodesj.setup(node_command, M.server.custom_server_filepath)
363+
elseif M.server.type == "binary" then
364+
lsp_binary.setup(M.server.custom_server_filepath)
353365
end
354366

355367
M.config = prepare_client_config(config.get("server_opts_overrides"))

lua/copilot/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ M.setup = function(opts)
4242
create_cmds()
4343
end
4444

45-
lsp_binary.setup(conf.lsp_binary)
4645
require("copilot.command").enable()
4746
logger.setup(conf.logger)
4847

lua/copilot/lsp_binary.lua

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -326,28 +326,27 @@ function M.get_server_path()
326326
return M.get_copilot_server_info().absolute_filepath
327327
end
328328

329-
---@param filepath string|nil
330-
function M.setup(filepath)
331-
if not filepath then
332-
return M
333-
end
329+
---@param custom_server_path? string
330+
function M.setup(custom_server_path)
331+
if custom_server_path then
332+
if not vim.fn.filereadable(custom_server_path) then
333+
logger.error("copilot-language-server not found at " .. custom_server_path)
334+
return M
335+
end
334336

335-
if not vim.fn.filereadable(filepath) then
336-
logger.error("copilot-language-server not found at " .. filepath)
337-
return M
338-
end
337+
logger.debug("using custom copilot-language-server binary:", custom_server_path)
338+
M.copilot_server_info = {
339+
path = "",
340+
filename = "",
341+
absolute_path = "",
342+
absolute_filepath = custom_server_path or "",
343+
extracted_filename = "",
344+
}
339345

340-
M.copilot_server_info = {
341-
path = "",
342-
filename = "",
343-
absolute_path = "",
344-
absolute_filepath = vim.fs.normalize(filepath),
345-
extracted_filename = "",
346-
}
347-
348-
logger.debug("using custom copilot-language-server binary:", M.copilot_server_info.absolute_filepath)
346+
M.initialized = true
347+
end
349348

350-
M.initialized = true
349+
M.ensure_client_is_downloaded()
351350
end
352351

353352
return M

0 commit comments

Comments
 (0)