-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcopilot.lua
50 lines (46 loc) · 1.09 KB
/
copilot.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if vim.g.loaded_coplilot then
return
end
vim.g.loaded_coplilot = true
require('copilot').setup({
suggestion = {
auto_trigger = true,
keymap = {
accept = false,
},
},
filetypes = {
markdown = false,
text = false,
tex = false,
[''] = false,
},
})
vim.defer_fn(function()
local suggestion = require('copilot.suggestion')
local key = require('utils.key')
key.amend('i', '<C-f>', function(fallback)
if suggestion.is_visible() then
suggestion.accept()
else
fallback()
end
end, { desc = '[copilot] accept suggestion' })
key.amend('i', '<M-f>', function(fallback)
if suggestion.is_visible() then
suggestion.accept_word()
else
fallback()
end
end, { desc = '[copilot] accept suggestion (word)' })
end, 10)
local copilot_util = require('copilot.util')
local _should_attach = copilot_util.should_attach
---Do not attach copilot to large files
---@diagnostic disable-next-line: duplicate-set-field
function copilot_util.should_attach(...)
if vim.b.bigfile then
return false
end
return _should_attach(...)
end