Skip to content

Commit 9ae1389

Browse files
committed
refactor: remove deprecated util usages
1 parent d1f5d0b commit 9ae1389

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

lua/copilot/command.lua

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function mod.version()
1313
"copilot.lua" .. " " .. u.get_copilot_lua_version(),
1414
}
1515

16-
local client = u.get_copilot_client()
16+
local client = c.get()
1717

1818
coroutine.wrap(function()
1919
if client then
@@ -49,7 +49,7 @@ function mod.status()
4949
vim.api.nvim_echo(lines, true, {})
5050
end
5151

52-
local client = u.get_copilot_client()
52+
local client = c.get()
5353
if not client then
5454
flush_lines("Not running")
5555
return
@@ -67,16 +67,16 @@ function mod.status()
6767
if not status.user then
6868
flush_lines("Not authenticated. Run ':Copilot auth'")
6969
return
70-
elseif status.status == 'NoTelemetryConsent' then
70+
elseif status.status == "NoTelemetryConsent" then
7171
flush_lines("Telemetry terms not accepted")
7272
return
73-
elseif status.status == 'NotAuthorized' then
73+
elseif status.status == "NotAuthorized" then
7474
flush_lines("Not authorized")
7575
return
7676
end
7777

7878
local should_attach, no_attach_reason = u.should_attach()
79-
local is_attached = u.is_attached(client)
79+
local is_attached = c.buf_is_attached()
8080
if is_attached then
8181
if not should_attach then
8282
add_line("Enabled manually (" .. no_attach_reason .. ")")
@@ -103,12 +103,7 @@ end
103103
function mod.toggle(opts)
104104
opts = opts or {}
105105

106-
local client = u.get_copilot_client()
107-
if not client then
108-
return
109-
end
110-
111-
if u.is_attached(client) then
106+
if c.buf_is_attached(0) then
112107
c.buf_detach()
113108
return
114109
end

lua/copilot/panel.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local api = require("copilot.api")
2+
local c = require("copilot.client")
23
local hl_group = require("copilot.highlight").group
34
local util = require("copilot.util")
45

@@ -355,7 +356,7 @@ function panel:refresh()
355356
return
356357
end
357358

358-
if not vim.lsp.buf_is_attached(0, self.client.id) then
359+
if not c.buf_is_attached(0) then
359360
return
360361
end
361362

@@ -483,7 +484,7 @@ function mod.refresh()
483484
end
484485

485486
function mod.open()
486-
local client = util.get_copilot_client()
487+
local client = c.get()
487488
if not client then
488489
print("Error, copilot not running")
489490
return

lua/copilot/suggestion.lua

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local api = require("copilot.api")
2+
local c = require("copilot.client")
23
local hl_group = require("copilot.highlight").group
34
local util = require("copilot.util")
45

@@ -26,23 +27,15 @@ local copilot = {
2627
debounce = 75,
2728
}
2829

29-
local function get_client()
30-
if not copilot.client then
31-
copilot.client = util.get_copilot_client()
32-
end
33-
return copilot.client
34-
end
35-
3630
local function with_client(fn)
37-
local client = get_client()
31+
local client = c.get()
3832
if client then
3933
fn(client)
4034
end
4135
end
4236

4337
local function is_enabled()
44-
local client = get_client()
45-
return client and vim.lsp.buf_is_attached(0, client.id) or false
38+
return c.buf_is_attached(0)
4639
end
4740

4841
local function should_auto_trigger()

0 commit comments

Comments
 (0)