Skip to content

Commit bdda0ea

Browse files
committed
fix: reuse of LSP client if the root dir and config name has not changed
Prevents scenarios where a second client could be created and cause and caught in store_client_id. May fix zbirenbaum#359
1 parent 30321e3 commit bdda0ea

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: lua/copilot/client.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ local function store_client_id(id)
2525
M.id = id
2626
end
2727

28+
local function reuse_client(client, conf)
29+
return client.config.root_dir == conf.root_dir and client.name == conf.name
30+
end
31+
2832
local lsp_start = vim.lsp.start
2933
if not lsp_start then
30-
local function reuse_client(client, conf)
31-
return client.config.root_dir == conf.root_dir and client.name == conf.name
32-
end
33-
3434
-- shim for neovim < 0.8.2
3535
lsp_start = function(lsp_config)
3636
local bufnr = vim.api.nvim_get_current_buf()
@@ -97,7 +97,7 @@ function M.buf_attach(force)
9797
return
9898
end
9999

100-
local client_id = lsp_start(M.config)
100+
local client_id = lsp_start(M.config, { reuse_client = reuse_client, bufnr = M.id })
101101
store_client_id(client_id)
102102
end
103103

0 commit comments

Comments
 (0)