LazyVim.LazyVim/lua/lazyvim/plugins/extras
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
..
ai feat(ai): better completion/suggestions of AI engines (#4752) 2024-11-11 10:50:57 +01:00
coding feat(ai): better completion/suggestions of AI engines (#4752) 2024-11-11 10:50:57 +01:00
dap fix(dap): use dap's splitstr when running with args. Closes #4387 2024-11-08 13:31:19 +01:00
editor fix(navic): use the same background color as lualine section_c (#4231) 2024-11-08 14:08:43 +01:00
formatting fix(prettier): keep existing formatters_by_ft (#4719) 2024-11-07 16:11:36 +01:00
lang feat(terraform): add formatter for packer files (#4591) 2024-11-08 21:14:22 +01:00
linting feat(eslint): add option to disable eslint auto format (#4225) 2024-11-08 14:05:00 +01:00
lsp feat: moved neoconf.nvim to extras 2024-06-02 09:05:16 +02:00
test fix(neotest): disambiguous key map descriptions (#4374) 2024-11-08 13:37:09 +01:00
ui fix(extras): fix alpha-nvim non-string keycodes (#4735) 2024-11-09 15:57:48 +01:00
util feat(rest): add more keymaps to util.rest (#4467) 2024-11-11 09:44:11 +01:00
vscode.lua fix(vscode): added snacks.nvim to allowed plugins for vscode. Fixes #4757 2024-11-11 09:41:45 +01:00