2023-03-03 08:22:20 +01:00
|
|
|
return {
|
2024-05-18 14:12:21 +02:00
|
|
|
recommended = true,
|
2023-03-03 08:22:20 +01:00
|
|
|
-- copilot
|
|
|
|
{
|
|
|
|
"zbirenbaum/copilot.lua",
|
|
|
|
cmd = "Copilot",
|
|
|
|
build = ":Copilot auth",
|
2025-01-31 20:10:48 +01:00
|
|
|
event = "BufReadPost",
|
2023-03-03 08:22:20 +01:00
|
|
|
opts = {
|
feat(ai): better completion/suggestions of AI engines (#4752)
## Description
The whole completion / snippets / AI is very tricky:
- multiple snippet engines
- native snippets on > 0.11 set their own keymaps, but not on 0.10
- multiple completion engines, like `nvim-cmp` and `blink.cmp`
- multiple ai completion engines that have a different API
- user's preference of showing ai suggestions as completion or not
- none of the ai completion engines currently set undo points, which is
bad
Solution:
- [x] added `LazyVim.cmp.actions`, where snippet engines and ai engines
can register their action.
- [x] an action returns `true` if it succeeded, or `false|nil` otherwise
- [x] in a completion engine, we then try running multiple actions and
use the fallback if needed
- [x] so `<tab>` runs `{"snippet_forward", "ai_accept", "fallback"}`
- [x] added `vim.g.ai_cmp`. When `true` we try to integrate the AI
source in the completion engine.
- [x] when `false`, `<tab>` should be used to insert the AI suggestion
- [x] when `false`, the completion engine's ghost text is disabled
- [x] luasnip support for blink (only works with blink `main`)
- [x] create undo points when accepting AI suggestions
## Test Matrix
| completion | snippets | ai | ai_cmp | tested? |
|--------------|--------------|-------------|--------|---------|
| nvim-cmp | native | copilot | true | ✅ |
| nvim-cmp | native | copilot | false | ✅ |
| nvim-cmp | native | codeium | true | ✅ |
| nvim-cmp | native | codeium | false | ✅ |
| nvim-cmp | luasnip | copilot | true | ✅ |
| nvim-cmp | luasnip | copilot | false | ✅ |
| nvim-cmp | luasnip | codeium | true | ✅ |
| nvim-cmp | luasnip | codeium | false | ✅ |
| blink.cmp | native | copilot | true | ✅ |
| blink.cmp | native | copilot | false | ✅ |
| blink.cmp | native | codeium | true | ✅ |
| blink.cmp | native | codeium | false | ✅ |
| blink.cmp | luasnip | copilot | true | ✅ |
| blink.cmp | luasnip | copilot | false | ✅ |
| blink.cmp | luasnip | codeium | true | ✅ |
| blink.cmp | luasnip | codeium | false | ✅ |
## Related Issue(s)
- [ ] Closes #4702
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Checklist
- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-11-11 10:50:57 +01:00
|
|
|
suggestion = {
|
|
|
|
enabled = not vim.g.ai_cmp,
|
|
|
|
auto_trigger = true,
|
2025-01-31 20:10:48 +01:00
|
|
|
hide_during_completion = vim.g.ai_cmp,
|
feat(ai): better completion/suggestions of AI engines (#4752)
## Description
The whole completion / snippets / AI is very tricky:
- multiple snippet engines
- native snippets on > 0.11 set their own keymaps, but not on 0.10
- multiple completion engines, like `nvim-cmp` and `blink.cmp`
- multiple ai completion engines that have a different API
- user's preference of showing ai suggestions as completion or not
- none of the ai completion engines currently set undo points, which is
bad
Solution:
- [x] added `LazyVim.cmp.actions`, where snippet engines and ai engines
can register their action.
- [x] an action returns `true` if it succeeded, or `false|nil` otherwise
- [x] in a completion engine, we then try running multiple actions and
use the fallback if needed
- [x] so `<tab>` runs `{"snippet_forward", "ai_accept", "fallback"}`
- [x] added `vim.g.ai_cmp`. When `true` we try to integrate the AI
source in the completion engine.
- [x] when `false`, `<tab>` should be used to insert the AI suggestion
- [x] when `false`, the completion engine's ghost text is disabled
- [x] luasnip support for blink (only works with blink `main`)
- [x] create undo points when accepting AI suggestions
## Test Matrix
| completion | snippets | ai | ai_cmp | tested? |
|--------------|--------------|-------------|--------|---------|
| nvim-cmp | native | copilot | true | ✅ |
| nvim-cmp | native | copilot | false | ✅ |
| nvim-cmp | native | codeium | true | ✅ |
| nvim-cmp | native | codeium | false | ✅ |
| nvim-cmp | luasnip | copilot | true | ✅ |
| nvim-cmp | luasnip | copilot | false | ✅ |
| nvim-cmp | luasnip | codeium | true | ✅ |
| nvim-cmp | luasnip | codeium | false | ✅ |
| blink.cmp | native | copilot | true | ✅ |
| blink.cmp | native | copilot | false | ✅ |
| blink.cmp | native | codeium | true | ✅ |
| blink.cmp | native | codeium | false | ✅ |
| blink.cmp | luasnip | copilot | true | ✅ |
| blink.cmp | luasnip | copilot | false | ✅ |
| blink.cmp | luasnip | codeium | true | ✅ |
| blink.cmp | luasnip | codeium | false | ✅ |
## Related Issue(s)
- [ ] Closes #4702
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Checklist
- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-11-11 10:50:57 +01:00
|
|
|
keymap = {
|
|
|
|
accept = false, -- handled by nvim-cmp / blink.cmp
|
|
|
|
next = "<M-]>",
|
|
|
|
prev = "<M-[>",
|
|
|
|
},
|
|
|
|
},
|
2023-03-03 08:22:20 +01:00
|
|
|
panel = { enabled = false },
|
2023-06-05 22:51:55 +02:00
|
|
|
filetypes = {
|
|
|
|
markdown = true,
|
|
|
|
help = true,
|
|
|
|
},
|
2023-03-03 08:22:20 +01:00
|
|
|
},
|
|
|
|
},
|
feat(ai): better completion/suggestions of AI engines (#4752)
## Description
The whole completion / snippets / AI is very tricky:
- multiple snippet engines
- native snippets on > 0.11 set their own keymaps, but not on 0.10
- multiple completion engines, like `nvim-cmp` and `blink.cmp`
- multiple ai completion engines that have a different API
- user's preference of showing ai suggestions as completion or not
- none of the ai completion engines currently set undo points, which is
bad
Solution:
- [x] added `LazyVim.cmp.actions`, where snippet engines and ai engines
can register their action.
- [x] an action returns `true` if it succeeded, or `false|nil` otherwise
- [x] in a completion engine, we then try running multiple actions and
use the fallback if needed
- [x] so `<tab>` runs `{"snippet_forward", "ai_accept", "fallback"}`
- [x] added `vim.g.ai_cmp`. When `true` we try to integrate the AI
source in the completion engine.
- [x] when `false`, `<tab>` should be used to insert the AI suggestion
- [x] when `false`, the completion engine's ghost text is disabled
- [x] luasnip support for blink (only works with blink `main`)
- [x] create undo points when accepting AI suggestions
## Test Matrix
| completion | snippets | ai | ai_cmp | tested? |
|--------------|--------------|-------------|--------|---------|
| nvim-cmp | native | copilot | true | ✅ |
| nvim-cmp | native | copilot | false | ✅ |
| nvim-cmp | native | codeium | true | ✅ |
| nvim-cmp | native | codeium | false | ✅ |
| nvim-cmp | luasnip | copilot | true | ✅ |
| nvim-cmp | luasnip | copilot | false | ✅ |
| nvim-cmp | luasnip | codeium | true | ✅ |
| nvim-cmp | luasnip | codeium | false | ✅ |
| blink.cmp | native | copilot | true | ✅ |
| blink.cmp | native | copilot | false | ✅ |
| blink.cmp | native | codeium | true | ✅ |
| blink.cmp | native | codeium | false | ✅ |
| blink.cmp | luasnip | copilot | true | ✅ |
| blink.cmp | luasnip | copilot | false | ✅ |
| blink.cmp | luasnip | codeium | true | ✅ |
| blink.cmp | luasnip | codeium | false | ✅ |
## Related Issue(s)
- [ ] Closes #4702
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Checklist
- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-11-11 10:50:57 +01:00
|
|
|
|
|
|
|
-- add ai_accept action
|
|
|
|
{
|
|
|
|
"zbirenbaum/copilot.lua",
|
|
|
|
opts = function()
|
|
|
|
LazyVim.cmp.actions.ai_accept = function()
|
|
|
|
if require("copilot.suggestion").is_visible() then
|
|
|
|
LazyVim.create_undo()
|
|
|
|
require("copilot.suggestion").accept()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
|
|
|
-- lualine
|
2023-04-21 08:46:45 +02:00
|
|
|
{
|
|
|
|
"nvim-lualine/lualine.nvim",
|
2023-05-22 20:38:46 +02:00
|
|
|
optional = true,
|
2023-04-21 08:46:45 +02:00
|
|
|
event = "VeryLazy",
|
|
|
|
opts = function(_, opts)
|
2024-11-13 17:20:50 +01:00
|
|
|
table.insert(
|
|
|
|
opts.sections.lualine_x,
|
|
|
|
2,
|
|
|
|
LazyVim.lualine.status(LazyVim.config.icons.kinds.Copilot, function()
|
|
|
|
local clients = package.loaded["copilot"] and LazyVim.lsp.get_clients({ name = "copilot", bufnr = 0 }) or {}
|
|
|
|
if #clients > 0 then
|
|
|
|
local status = require("copilot.api").status.data.status
|
|
|
|
return (status == "InProgress" and "pending") or (status == "Warning" and "error") or "ok"
|
2023-10-09 09:12:48 +02:00
|
|
|
end
|
2024-11-13 17:20:50 +01:00
|
|
|
end)
|
|
|
|
)
|
2023-04-21 08:46:45 +02:00
|
|
|
end,
|
|
|
|
},
|
2023-03-03 08:22:20 +01:00
|
|
|
|
2024-12-12 13:32:56 +01:00
|
|
|
vim.g.ai_cmp
|
|
|
|
and {
|
|
|
|
-- copilot cmp source
|
|
|
|
{
|
2024-12-12 14:45:47 +01:00
|
|
|
"hrsh7th/nvim-cmp",
|
2024-12-12 13:32:56 +01:00
|
|
|
optional = true,
|
|
|
|
dependencies = { -- this will only be evaluated if nvim-cmp is enabled
|
|
|
|
{
|
|
|
|
"zbirenbaum/copilot-cmp",
|
|
|
|
opts = {},
|
|
|
|
config = function(_, opts)
|
|
|
|
local copilot_cmp = require("copilot_cmp")
|
|
|
|
copilot_cmp.setup(opts)
|
|
|
|
-- attach cmp source whenever copilot attaches
|
|
|
|
-- fixes lazy-loading issues with the copilot cmp source
|
|
|
|
LazyVim.lsp.on_attach(function()
|
|
|
|
copilot_cmp._on_insert_enter({})
|
|
|
|
end, "copilot")
|
|
|
|
end,
|
|
|
|
specs = {
|
|
|
|
{
|
2024-12-12 14:45:47 +01:00
|
|
|
"hrsh7th/nvim-cmp",
|
2024-12-12 13:32:56 +01:00
|
|
|
optional = true,
|
|
|
|
---@param opts cmp.ConfigSchema
|
|
|
|
opts = function(_, opts)
|
|
|
|
table.insert(opts.sources, 1, {
|
|
|
|
name = "copilot",
|
|
|
|
group_index = 1,
|
|
|
|
priority = 100,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
feat(ai): better completion/suggestions of AI engines (#4752)
## Description
The whole completion / snippets / AI is very tricky:
- multiple snippet engines
- native snippets on > 0.11 set their own keymaps, but not on 0.10
- multiple completion engines, like `nvim-cmp` and `blink.cmp`
- multiple ai completion engines that have a different API
- user's preference of showing ai suggestions as completion or not
- none of the ai completion engines currently set undo points, which is
bad
Solution:
- [x] added `LazyVim.cmp.actions`, where snippet engines and ai engines
can register their action.
- [x] an action returns `true` if it succeeded, or `false|nil` otherwise
- [x] in a completion engine, we then try running multiple actions and
use the fallback if needed
- [x] so `<tab>` runs `{"snippet_forward", "ai_accept", "fallback"}`
- [x] added `vim.g.ai_cmp`. When `true` we try to integrate the AI
source in the completion engine.
- [x] when `false`, `<tab>` should be used to insert the AI suggestion
- [x] when `false`, the completion engine's ghost text is disabled
- [x] luasnip support for blink (only works with blink `main`)
- [x] create undo points when accepting AI suggestions
## Test Matrix
| completion | snippets | ai | ai_cmp | tested? |
|--------------|--------------|-------------|--------|---------|
| nvim-cmp | native | copilot | true | ✅ |
| nvim-cmp | native | copilot | false | ✅ |
| nvim-cmp | native | codeium | true | ✅ |
| nvim-cmp | native | codeium | false | ✅ |
| nvim-cmp | luasnip | copilot | true | ✅ |
| nvim-cmp | luasnip | copilot | false | ✅ |
| nvim-cmp | luasnip | codeium | true | ✅ |
| nvim-cmp | luasnip | codeium | false | ✅ |
| blink.cmp | native | copilot | true | ✅ |
| blink.cmp | native | copilot | false | ✅ |
| blink.cmp | native | codeium | true | ✅ |
| blink.cmp | native | codeium | false | ✅ |
| blink.cmp | luasnip | copilot | true | ✅ |
| blink.cmp | luasnip | copilot | false | ✅ |
| blink.cmp | luasnip | codeium | true | ✅ |
| blink.cmp | luasnip | codeium | false | ✅ |
## Related Issue(s)
- [ ] Closes #4702
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Checklist
- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-11-11 10:50:57 +01:00
|
|
|
},
|
|
|
|
},
|
2024-12-12 13:32:56 +01:00
|
|
|
{
|
|
|
|
"saghen/blink.cmp",
|
|
|
|
optional = true,
|
|
|
|
dependencies = { "giuxtaposition/blink-cmp-copilot" },
|
|
|
|
opts = {
|
|
|
|
sources = {
|
|
|
|
default = { "copilot" },
|
|
|
|
providers = {
|
|
|
|
copilot = {
|
|
|
|
name = "copilot",
|
|
|
|
module = "blink-cmp-copilot",
|
|
|
|
kind = "Copilot",
|
2024-12-15 18:33:50 +01:00
|
|
|
score_offset = 100,
|
|
|
|
async = true,
|
2024-12-12 13:32:56 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-11-13 18:28:58 +01:00
|
|
|
},
|
|
|
|
},
|
2024-12-12 13:32:56 +01:00
|
|
|
}
|
|
|
|
or nil,
|
2023-03-03 08:22:20 +01:00
|
|
|
}
|