Skip to content

Commit dd79629

Browse files
committed
feat: add force enable instruction in ':Copilot toggle'
1 parent c9f4240 commit dd79629

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lua/copilot/command.lua

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,23 @@ function mod.toggle(opts)
103103

104104
if u.is_attached(client) then
105105
c.buf_detach(client)
106-
else
107-
c.buf_attach(client, opts.force)
106+
return
107+
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+
return
117+
end
118+
119+
opts.force = true
108120
end
121+
122+
c.buf_attach(client, opts.force)
109123
end
110124

111125
return mod

0 commit comments

Comments
 (0)