File tree Expand file tree Collapse file tree 2 files changed +28
-11
lines changed
Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -39,18 +39,18 @@ M.start = function(plugin_path)
3939 root_dir = vim .loop .cwd (),
4040 autostart = true ,
4141 on_init = function (client , _ )
42- vim .lsp .buf_attach_client (0 , client .id )
43- vim .api .nvim_create_autocmd ({ " BufEnter" }, {
44- callback = function ()
45- if not vim .lsp .buf_get_clients (0 )[client .id ] then
46- vim .lsp .buf_attach_client (0 , client .id )
47- end
48- end ,
49- once = false ,
50- })
51- end ,
52- on_attach = function ()
5342 send_editor_info ()
43+ vim .lsp .buf_attach_client (0 , client .id )
44+ if vim .fn .has (" nvim-0.7" ) then
45+ vim .api .nvim_create_autocmd ({ " BufEnter" }, {
46+ callback = function ()
47+ util .attach_copilot ()
48+ end ,
49+ once = false ,
50+ })
51+ else
52+ vim .cmd (" au BufEnter * lua require('copilot.util').attach_copilot()" )
53+ end
5454 end ,
5555 })
5656end
Original file line number Diff line number Diff line change 11local M = {}
22
3+
34local format_pos = function ()
45 local pos = vim .api .nvim_win_get_cursor (0 )
56 return { character = pos [2 ], line = pos [1 ] - 1 }
@@ -10,6 +11,22 @@ local get_relfile = function()
1011 return file
1112end
1213
14+ M .find_copilot_client = function ()
15+ for _ , client in ipairs (vim .lsp .get_active_clients ()) do
16+ if client .name == " copilot" then
17+ return client .id
18+ end
19+ end
20+ print (" Copilot not started!" )
21+ end
22+
23+ M .attach_copilot = function ()
24+ local client_id = require (" copilot.util" ).find_copilot_client ()
25+ if not vim .lsp .buf_get_clients (0 )[client_id ] then
26+ vim .lsp .buf_attach_client (0 , client_id )
27+ end
28+ end
29+
1330M .get_completion_params = function ()
1431 local params = {
1532 options = vim .empty_dict (),
You can’t perform that action at this time.
0 commit comments