File tree Expand file tree Collapse file tree 4 files changed +21
-6
lines changed
Expand file tree Collapse file tree 4 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ local M = {}
22
33local defaults = {
44 plugin_manager_path = vim .fn .stdpath (" data" ) .. " /site/pack/packer" ,
5+ on_attach = function ()
6+ require (" copilot_cmp" )._on_insert_enter ()
7+ end ,
58}
69
710M .params = {}
Original file line number Diff line number Diff line change 1818local capabilities = vim .lsp .protocol .make_client_capabilities ()
1919capabilities .getCompletions = true
2020
21- M .start = function (plugin_path )
21+ M .start = function (params )
2222 vim .lsp .start_client ({
23- cmd = { require (" copilot.util" ).get_copilot_path (plugin_path ) },
23+ cmd = { require (" copilot.util" ).get_copilot_path (params . plugin_manager_path ) },
2424 cmd_env = {
2525 [" GITHUB_USER" ] = user_data .user ,
2626 [" GITHUB_TOKEN" ] = user_data .token ,
@@ -52,6 +52,11 @@ M.start = function(plugin_path)
5252 vim .cmd (" au BufEnter * lua require('copilot.util').attach_copilot()" )
5353 end
5454 end ,
55+ on_attach = function ()
56+ vim .schedule (function ()
57+ params .on_attach ()
58+ end )
59+ end ,
5560 })
5661end
5762
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ local M = {}
44M .setup = function (params )
55 config .setup (params )
66 config .params .plugin_manager_path = vim .fn .expand (config .params .plugin_manager_path ) -- resolve wildcard and variable containing paths
7- require (" copilot.copilot_handler" ).start (config .params . plugin_manager_path )
7+ require (" copilot.copilot_handler" ).start (config .params )
88end
99
1010return M
Original file line number Diff line number Diff line change @@ -11,16 +11,23 @@ local get_relfile = function()
1111 return file
1212end
1313
14- M .find_copilot_client = function ()
14+ M .find_copilot_client = function ()
1515 for _ , client in ipairs (vim .lsp .get_active_clients ()) do
1616 if client .name == " copilot" then
1717 return client .id
1818 end
1919 end
20- print (" Copilot not started!" )
2120end
2221
23- M .attach_copilot = function ()
22+ M .find_copilot_buf_client = function ()
23+ for _ , client in ipairs (vim .lsp .buf_get_clients (0 )) do
24+ if client .name == " copilot" then
25+ return client .id
26+ end
27+ end
28+ end
29+
30+ M .attach_copilot = function ()
2431 local client_id = require (" copilot.util" ).find_copilot_client ()
2532 if not vim .lsp .buf_get_clients (0 )[client_id ] then
2633 vim .lsp .buf_attach_client (0 , client_id )
You can’t perform that action at this time.
0 commit comments