File tree Expand file tree Collapse file tree 4 files changed +562
-0
lines changed
Expand file tree Collapse file tree 4 files changed +562
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,17 @@ The following is the default configuration:
6565panel = { -- no config options yet
6666 enabled = true ,
6767},
68+ suggestion = {
69+ enabled = true ,
70+ auto_trigger = false ,
71+ debounce = 75 ,
72+ keymap = {
73+ accept = " <M-l>" ,
74+ next = " <M-]>" ,
75+ prev = " <M-[>" ,
76+ dismiss = " <C-]>" ,
77+ },
78+ },
6879ft_disable = {},
6980copilot_node_command = ' node' , -- Node version must be < 18
7081plugin_manager_path = vim .fn .stdpath (" data" ) .. " /site/pack/packer" ,
@@ -84,6 +95,29 @@ require("copilot").setup {
8495
8596```
8697
98+ #### suggestion
99+
100+ When ` auto_trigger ` is ` true ` , copilot starts suggesting as soon as you enter insert mode.
101+
102+ When ` auto_trigger ` is ` false ` , use the ` next ` or ` prev ` keymap to trigger copilot suggestion.
103+
104+ To toggle auto trigger for the current buffer, use ` require("copilot.suggestion").toggle_auto_trigger() ` .
105+
106+ Copilot suggestion is automatically hidden when ` popupmenu-completion ` is open. In case you use a custom
107+ menu for completion, you can set the ` copilot_suggestion_hidden ` buffer variable to ` true ` to have the
108+ same behavior. For example, with ` nvim-cmp ` :
109+
110+ ``` lua
111+ cmp .event :on (" menu_opened" , function ()
112+ vim .b .copilot_suggestion_hidden = true
113+ end )
114+
115+ cmp .event :on (" menu_closed" , function ()
116+ vim .b .copilot_suggestion_hidden = false
117+ end )
118+ ```
119+
120+
87121##### ft_disable
88122
89123Prevents copilot from attaching to buffers with specific filetypes.
Original file line number Diff line number Diff line change 1+ local mod = {
2+ group = {
3+ CopilotAnnotation = " CopilotAnnotation" ,
4+ CopilotSuggestion = " CopilotSuggestion" ,
5+ },
6+ }
7+
8+ local links = {
9+ [mod .group .CopilotAnnotation ] = " Comment" ,
10+ [mod .group .CopilotSuggestion ] = " Comment" ,
11+ }
12+
13+ function mod .setup ()
14+ for from_group , to_group in pairs (links ) do
15+ vim .api .nvim_command (" highlight default link " .. from_group .. " " .. to_group )
16+ end
17+ end
18+
19+ return mod
Original file line number Diff line number Diff line change 11local M = { client_info = nil }
22local client = require (" copilot.client" )
3+ local highlight = require (" copilot.highlight" )
4+ local suggestion = require (" copilot.suggestion" )
35local defaults = {
46 panel = { -- no config options yet
57 enabled = true ,
68 },
9+ suggestion = {
10+ enabled = true ,
11+ auto_trigger = false ,
12+ debounce = 75 ,
13+ keymap = {
14+ accept = " <M-l>" ,
15+ next = " <M-]>" ,
16+ prev = " <M-[>" ,
17+ dismiss = " <C-]>" ,
18+ }
19+ },
720 ft_disable = {},
821 copilot_node_command = " node" ,
922 plugin_manager_path = vim .fn .stdpath (" data" ) .. " /site/pack/packer" ,
@@ -49,7 +62,12 @@ M.setup = function(opts)
4962 create_cmds (user_config )
5063 end
5164
65+ if user_config .suggestion .enabled then
66+ suggestion .setup (user_config .suggestion )
67+ end
5268 end )
69+
70+ highlight .setup ()
5371end
5472
5573return M
You can’t perform that action at this time.
0 commit comments