Skip to content

Commit 81cba6d

Browse files
committed
fix: fail to start when not using lazy loading of plugin
fixes: #523
1 parent 045daa5 commit 81cba6d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lua/copilot/client/init.lua

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ function M.buf_attach(force)
6464

6565
logger.trace("attaching to buffer")
6666

67-
-- This could cause slowdowns when going into Insert mode
68-
if not vim.lsp.buf_is_attached(bufnr, M.id) then
67+
if not M.id then
6968
M.ensure_client_started()
69+
end
7070

71-
if not M.id then
72-
return
73-
end
71+
if not M.id then
72+
logger.trace("failed to start copilot client")
73+
return
74+
end
7475

76+
-- This could cause slowdowns when going into Insert mode
77+
if not vim.lsp.buf_is_attached(bufnr, M.id) then
7578
vim.lsp.buf_attach_client(bufnr, M.id)
7679
logger.trace("explicitly attached client to buffer")
7780
end
@@ -156,7 +159,7 @@ function M.setup()
156159
end),
157160
})
158161

159-
M.ensure_client_started()
162+
vim.schedule(M.ensure_client_started)
160163
end
161164

162165
function M.teardown()

0 commit comments

Comments
 (0)