LazyVim.LazyVim/lua/lazyvim/plugins
Folke Lemaitre fbf881f80b
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
..
compat fix(extras): better reasons as to why some extras are included in your config. 2024-06-14 11:14:00 +02:00
extras feat(ai): better completion/suggestions of AI engines (#4752) 2024-11-11 10:50:57 +01:00
lsp fix(lsp): wrap hover and signature_help 2024-11-08 16:55:40 +01:00
coding.lua feat(ai): better completion/suggestions of AI engines (#4752) 2024-11-11 10:50:57 +01:00
colorscheme.lua fix(catppuccin): fix bufferline integration when no colorscheme is set. Closes #4641 2024-10-24 07:58:14 +02:00
editor.lua feat(core)!: move a bunch of LazyVim features to snacks.nvim (#4706) 2024-11-07 15:54:47 +01:00
formatting.lua fix(conform): changes for new conform.nvim config 2024-07-20 17:14:07 +02:00
init.lua fix(snacks): allow overriding statuscolumn through options.lua 2024-11-11 09:37:47 +01:00
linting.lua fix(lint): make prepend_args opt work when default args is empty (#3828) 2024-06-27 17:31:11 +02:00
treesitter.lua feat(keymaps): dynamic which-key icons/descriptions for toggles (#4050) 2024-07-15 15:47:44 +02:00
ui.lua feat(keymaps): leader-bo to close other buffers 2024-11-09 16:13:11 +01:00
util.lua feat(persistence): added leader-qS to select a session 2024-08-31 09:27:14 +02:00
xtras.lua feat(extras): blink (#4680) 2024-11-02 09:54:55 +01:00