Skip to content

Commit ca68fc3

Browse files
committed
refactor: initial setup
1 parent dc4006f commit ca68fc3

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

lua/copilot/init.lua

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
local M = { setup_done = false }
22
local config = require("copilot.config")
3-
local client = require("copilot.client")
43
local highlight = require("copilot.highlight")
5-
local panel = require("copilot.panel")
6-
local suggestion = require("copilot.suggestion")
74

8-
local create_cmds = function (_)
5+
local create_cmds = function ()
96
vim.api.nvim_create_user_command("CopilotDetach", function()
10-
local client_instance = require("copilot.util").get_copilot_client()
11-
local valid = client_instance and vim.lsp.buf_is_attached(0, client_instance.id)
12-
if not valid then return end
13-
vim.lsp.buf_detach_client(0, client_instance.id)
7+
if require("copilot.client").buf_is_attached(0) then
8+
vim.deprecate("':CopilotDetach'", "':Copilot detach'", "in future", "copilot.lua")
9+
vim.cmd("Copilot detach")
10+
end
1411
end, {})
1512

1613
vim.api.nvim_create_user_command("CopilotStop", function()
17-
local client_instance = require("copilot.util").get_copilot_client()
18-
if not client_instance then return end
19-
vim.lsp.stop_client(client_instance.id)
14+
vim.deprecate("':CopilotStop'", "':Copilot disable'", "in future", "copilot.lua")
15+
vim.cmd("Copilot disable")
2016
end, {})
2117

2218
vim.api.nvim_create_user_command("CopilotPanel", function ()
@@ -35,20 +31,14 @@ M.setup = function(opts)
3531
return
3632
end
3733

38-
local conf = config.setup(opts)
39-
40-
client.setup(conf)
34+
highlight.setup()
4135

36+
local conf = config.setup(opts)
4237
if conf.panel.enabled then
43-
panel.setup(conf.panel)
44-
create_cmds(conf)
38+
create_cmds()
4539
end
4640

47-
if conf.suggestion.enabled then
48-
suggestion.setup(conf.suggestion)
49-
end
50-
51-
highlight.setup()
41+
require("copilot.command").enable()
5242

5343
M.setup_done = true
5444
end

0 commit comments

Comments
 (0)