File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,26 @@ local function store_client_id(id)
1616 M .id = id
1717end
1818
19+ local lsp_start = vim .lsp .start
20+ if not lsp_start then
21+ local function reuse_client (client , conf )
22+ return client .config .root_dir == conf .root_dir and client .name == conf .name
23+ end
24+
25+ -- shim for neovim < 0.8.2
26+ lsp_start = function (lsp_config )
27+ local bufnr = vim .api .nvim_get_current_buf ()
28+ local client = M .get ()
29+ if client and reuse_client (client , lsp_config ) then
30+ vim .lsp .buf_attach_client (bufnr , client .id )
31+ return client .id
32+ end
33+ local client_id = vim .lsp .start_client (lsp_config ) --[[ @as number]]
34+ vim .lsp .buf_attach_client (bufnr , client_id )
35+ return client_id
36+ end
37+ end
38+
1939local copilot_node_version = nil
2040function M .get_node_version ()
2141 if not copilot_node_version then
@@ -37,7 +57,7 @@ function M.buf_attach(force)
3757 return
3858 end
3959
40- local client_id = vim . lsp . start (M .config )
60+ local client_id = lsp_start (M .config )
4161 store_client_id (client_id )
4262end
4363
You can’t perform that action at this time.
0 commit comments