We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c9f4240 commit dd79629Copy full SHA for dd79629
lua/copilot/command.lua
@@ -103,9 +103,23 @@ function mod.toggle(opts)
103
104
if u.is_attached(client) then
105
c.buf_detach(client)
106
- else
107
- c.buf_attach(client, opts.force)
+ return
+ end
108
+
109
+ if not opts.force then
110
+ local should_attach, no_attach_reason = u.should_attach(c.params.filetypes)
111
+ if not should_attach then
112
+ vim.api.nvim_echo({
113
+ { "[Copilot] " .. no_attach_reason .. "\n" },
114
+ { "[Copilot] to force enable, run ':Copilot! toggle'" },
115
+ }, true, {})
116
117
118
119
+ opts.force = true
120
end
121
122
+ c.buf_attach(client, opts.force)
123
124
125
return mod
0 commit comments