Skip to content

Commit 9b32d2f

Browse files
committed
remove other instance of using nightly features
1 parent 4d102aa commit 9b32d2f

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

lua/copilot/client.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ end
99
M.buf_attach_copilot = function()
1010
if vim.tbl_contains(M.params.ft_disable, vim.bo.filetype) then return end
1111
if not vim.bo.buflisted or not vim.bo.buftype == "" then return end
12-
local name = M.params.server_opts_overrides.name or "copilot"
13-
1412
-- The filter param to get_active_clients() can be used on Neovim 0.8 and later.
1513
for _, client in pairs(vim.lsp.get_active_clients()) do
16-
if client.name == name and not vim.lsp.buf_is_attached(0, client.id) then
14+
if client.name == "copilot" and not vim.lsp.buf_is_attached(0, client.id) then
1715
vim.lsp.buf_attach_client(0, client.id)
1816
client.completion_function = M.params.extensions
1917
end

lua/copilot/extensions/panel.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ local panel = {
1010

1111
panel.send_request = function (opts)
1212
opts = opts or {}
13-
local client = opts.client or not vim.tbl_isempty(panel.client) and panel.client or vim.lsp.get_active_clients({name="copilot"})[1]
13+
local client = opts.client or not vim.tbl_isempty(panel.client) and panel.client or util.get_copilot_client()
1414
if not panel.client then return end
1515
local completion_params = util.get_completion_params()
1616
completion_params.panelId = opts.uri or panel.uri
@@ -19,7 +19,7 @@ panel.send_request = function (opts)
1919
end
2020

2121
function panel.create (client, max_results)
22-
panel.client = client or vim.lsp.get_active_clients({name="copilot"})[1]
22+
panel.client = client or util.get_copilot_client()
2323
if not panel.client then print("Error, copilot not running") end
2424
panel.max_results = max_results or 10
2525
panel.buf = type(panel.uri) == "number" or vim.api.nvim_create_buf(false, true)

lua/copilot/extensions/print_panel.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local a = vim.api
2+
local cmd = vim.cmd
23
local wo = vim.wo
34
local handler = require("copilot.handlers")
45
local format = require("copilot_cmp.format")
@@ -91,7 +92,7 @@ print_panel.select = function (id)
9192
if not id then id = print_panel.current or 1 end
9293
local selection = print_panel.entries[id]
9394
a.nvim_win_set_cursor(print_panel.win, {selection.linenr, 0})
94-
vim.cmd("normal zt")
95+
cmd("normal zt")
9596
print_panel.current = id
9697
print_panel.linenr = selection.linenr
9798
end

lua/copilot/util.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ local get_relfile = function()
1010
return file
1111
end
1212

13-
M.find_copilot_client = function()
14-
vim.lsp.get_active_clients({name="copilot"})
13+
M.get_copilot_client = function()
14+
-- vim.lsp.get_active_clients({name="copilot"}) -- not in 0.7
15+
for _, client in pairs(vim.lsp.get_active_clients()) do
16+
if client.name == "copilot" then return client end
17+
end
1518
end
1619

1720
M.get_completion_params = function()

0 commit comments

Comments
 (0)