Skip to content

Commit 5c7701a

Browse files
committed
attempt 2
1 parent 16f0ac0 commit 5c7701a

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lua/copilot/auth/init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ function M.pass_gate()
2424
gate_passed = true
2525
require("copilot.suggestion").setup()
2626
require("copilot.panel").setup()
27+
28+
-- Set suggestion keymaps on buffers that were attached before auth passed
29+
local client = c.get()
30+
if client then
31+
local suggestion = require("copilot.suggestion")
32+
for _, bufnr in ipairs(vim.lsp.get_buffers_by_client_id(client.id)) do
33+
suggestion.set_keymap(bufnr)
34+
end
35+
end
2736
end
2837

2938
---@return boolean

lua/copilot/client/init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ function M.buf_attach(force, bufnr)
102102
end
103103

104104
vim.lsp.buf_attach_client(bufnr, M.id)
105-
require("copilot.suggestion").set_keymap(bufnr)
105+
if require("copilot.auth").is_gate_passed() then
106+
require("copilot.suggestion").set_keymap(bufnr)
107+
end
106108
require("copilot.nes").set_keymap(bufnr)
107109

108110
util.set_buffer_previous_ft(bufnr, vim.bo[bufnr].filetype)

0 commit comments

Comments
 (0)