2024-05-16 18:03:58 +02:00
|
|
|
return {
|
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
|
|
|
-- disable builtin snippet support
|
|
|
|
{ "garymjr/nvim-snippets", enabled = false },
|
|
|
|
|
|
|
|
-- add luasnip
|
2024-06-02 18:43:44 +02:00
|
|
|
{
|
|
|
|
"L3MON4D3/LuaSnip",
|
2024-07-14 18:19:28 +02:00
|
|
|
lazy = true,
|
2024-06-02 18:43:44 +02:00
|
|
|
build = (not LazyVim.is_win())
|
|
|
|
and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp"
|
|
|
|
or nil,
|
|
|
|
dependencies = {
|
|
|
|
{
|
|
|
|
"rafamadriz/friendly-snippets",
|
|
|
|
config = function()
|
|
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
2024-12-11 11:13:57 +01:00
|
|
|
require("luasnip.loaders.from_vscode").lazy_load({ paths = { vim.fn.stdpath("config") .. "/snippets" } })
|
2024-06-02 18:43:44 +02:00
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
opts = {
|
|
|
|
history = true,
|
|
|
|
delete_check_events = "TextChanged",
|
2024-05-16 18:03:58 +02: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 snippet_forward action
|
|
|
|
{
|
|
|
|
"L3MON4D3/LuaSnip",
|
|
|
|
opts = function()
|
|
|
|
LazyVim.cmp.actions.snippet_forward = function()
|
|
|
|
if require("luasnip").jumpable(1) then
|
|
|
|
require("luasnip").jump(1)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
|
|
|
-- nvim-cmp integration
|
2024-06-02 18:43:44 +02:00
|
|
|
{
|
|
|
|
"nvim-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
|
|
|
optional = true,
|
|
|
|
dependencies = { "saadparwaiz1/cmp_luasnip" },
|
|
|
|
opts = function(_, opts)
|
|
|
|
opts.snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
require("luasnip").lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
table.insert(opts.sources, { name = "luasnip" })
|
|
|
|
end,
|
2024-05-16 18:03:58 +02:00
|
|
|
-- stylua: ignore
|
|
|
|
keys = {
|
|
|
|
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
|
|
|
|
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
|
|
|
|
},
|
2024-06-02 18:43:44 +02: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
|
|
|
|
|
|
|
-- blink.cmp integration
|
2024-06-09 07:37:09 +02: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
|
|
|
"saghen/blink.cmp",
|
|
|
|
optional = true,
|
2024-11-28 07:39:10 +01:00
|
|
|
dependencies = {
|
|
|
|
{ "saghen/blink.compat", opts = { impersonate_nvim_cmp = true } },
|
|
|
|
{ "saadparwaiz1/cmp_luasnip" },
|
|
|
|
},
|
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
|
|
|
opts = {
|
2024-11-28 07:39:10 +01:00
|
|
|
sources = { compat = { "luasnip" } },
|
|
|
|
snippets = {
|
|
|
|
expand = function(snippet)
|
|
|
|
require("luasnip").lsp_expand(snippet)
|
|
|
|
end,
|
|
|
|
active = function(filter)
|
|
|
|
if filter and filter.direction then
|
|
|
|
return require("luasnip").jumpable(filter.direction)
|
|
|
|
end
|
|
|
|
return require("luasnip").in_snippet()
|
|
|
|
end,
|
|
|
|
jump = function(direction)
|
|
|
|
require("luasnip").jump(direction)
|
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
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
2024-06-09 07:37:09 +02:00
|
|
|
},
|
2024-05-16 18:03:58 +02:00
|
|
|
}
|