Skip to content

Commit 2bd8d80

Browse files
committed
add CopilotDetach and CopilotStop commands
1 parent c2e90de commit 2bd8d80

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lua/copilot/init.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ local defaults = {
1515
}
1616

1717
local create_cmds = function (_)
18+
vim.api.nvim_create_user_command("CopilotDetach", function()
19+
local client_instance = require("copilot.util").get_copilot_client()
20+
local valid = client_instance and vim.lsp.buf_is_attached(0, client_instance.id)
21+
if not valid then return end
22+
vim.lsp.buf_detach_client(0, client_instance.id)
23+
end, {})
24+
25+
vim.api.nvim_create_user_command("CopilotStop", function()
26+
local client_instance = require("copilot.util").get_copilot_client()
27+
if not client_instance then return end
28+
vim.lsp.stop_client(client_instance.id)
29+
end, {})
30+
1831
vim.api.nvim_create_user_command("CopilotPanel", function ()
1932
local panel = require("copilot.extensions.panel").create()
2033
panel.send_request()

0 commit comments

Comments
 (0)