nvim: Add copilot suggestions to blink
Suggestions are given at the top of the completion menu. Additionally, since that can get really annoying really quick there have been some changes specifically for copilot.lua: We start with it disabled. It can be enabled with `<leader>ap` and disabled again with `<leader>aP` for Ai>coPilot. If the plugin at some point exposes functionality to toggle itself on/off completely I would gladly switch to that. The current toggle command only attaches/detaches the buffer but still runs the client in the background. This is less desirable for me, plus it means the completions are still done automatically in blink.
This commit is contained in:
parent
6106cfcbde
commit
1f328d2663
2 changed files with 63 additions and 5 deletions
|
|
@ -3,6 +3,7 @@
|
|||
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
|
||||
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
||||
"bats.vim": { "branch": "master", "commit": "6a5d2ef22b0ede503d867770afd02ebb1f97b709" },
|
||||
"blink-copilot": { "branch": "main", "commit": "41e91a659bd9b8cba9ba2ea68a69b52ba5a9ebd8" },
|
||||
"blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" },
|
||||
"blink.compat": { "branch": "main", "commit": "2ed6d9a28b07fa6f3bface818470605f8896408c" },
|
||||
"cmp-calc": { "branch": "main", "commit": "5947b412da67306c5b68698a02a846760059be2e" },
|
||||
|
|
|
|||
|
|
@ -2,22 +2,79 @@ return {
|
|||
{
|
||||
-- NOTE: Requires manual auth with ':Copilot auth' or 'GH_COPILOT_TOKEN' set as envvar
|
||||
"zbirenbaum/copilot.lua",
|
||||
dependencies = { "AndreM222/copilot-lualine" },
|
||||
dependencies = {
|
||||
"AndreM222/copilot-lualine",
|
||||
{ -- show completions in blink
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"fang2hou/blink-copilot",
|
||||
opts = {
|
||||
auto_refresh = {
|
||||
backward = false,
|
||||
forward = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
sources = {
|
||||
default = { "copilot" },
|
||||
providers = {
|
||||
copilot = {
|
||||
name = "copilot",
|
||||
module = "blink-copilot",
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
cmd = "Copilot",
|
||||
event = "InsertEnter",
|
||||
event = { "InsertEnter", "VeryLazy" },
|
||||
opts = {
|
||||
panel = { layout = { position = "bottom" } },
|
||||
suggestion = { keymap = { accept = "<M-p>" } },
|
||||
logger = { print_log_level = vim.log.levels.ERROR },
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("copilot").setup(opts)
|
||||
-- TODO: See also https://github.com/zbirenbaum/copilot.lua/issues/302 for potential
|
||||
-- better solutions.
|
||||
-- TODO: also Find way of having a 'toggle' for mapping below.
|
||||
-- Current copilot.lua exposed 'toggle' command does NOT do the same.
|
||||
require("copilot.command").disable()
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>ap",
|
||||
"<leader>aC",
|
||||
function()
|
||||
-- FIXME: If opening before lazy-loaded, errors
|
||||
require("copilot.panel").setup()
|
||||
require("copilot.panel").open({})
|
||||
require("copilot.panel").refresh()
|
||||
end,
|
||||
desc = "Refresh Copilot Panel",
|
||||
desc = "Open copilot panel",
|
||||
silent = true,
|
||||
mode = { "n" },
|
||||
},
|
||||
{
|
||||
"<leader>ap",
|
||||
function()
|
||||
require("copilot.command").enable()
|
||||
end,
|
||||
desc = "Enable copilot",
|
||||
silent = true,
|
||||
mode = { "n" },
|
||||
},
|
||||
{
|
||||
"<leader>aP",
|
||||
function()
|
||||
require("copilot.command").disable()
|
||||
end,
|
||||
desc = "Disable copilot",
|
||||
silent = true,
|
||||
mode = { "n" },
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue