Skip to content

Commit caf4be6

Browse files
committed
feat(ai): add basic configuration code for various AI plugins
1 parent 94c1ac7 commit caf4be6

File tree

1 file changed

+105
-1
lines changed
  • src/content/docs/recipes

1 file changed

+105
-1
lines changed

src/content/docs/recipes/ai.mdx

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,114 @@ return {
106106

107107
### AI Plugin Integration
108108

109-
Once our completion engine is configured, we can start choosing and adding in an AI plugin from the Neovim plugin ecosystem, and setting up the `vim.g.ai_accept` function appropriately to hook into the completion engine mappings that we previously set up.
109+
Once our completion engine is configured, we can start choosing and adding in an AI plugin from the Neovim plugin ecosystem, and setting up the `vim.g.ai_accept` function appropriately to hook into the completion engine mappings that we previously set up. Please note that further configuration may be necessary if you want to use completion sources rather than inline suggestions or change other behavior of the AI plugins. For that setup, please refer to the documentation of the plugins themselves.
110110

111111
#### [copilot.lua](https://github.com/zbirenbaum/copilot.lua)
112112

113+
```lua title="lua/plugins/copilot.lua"
114+
return {
115+
"zbirenbaum/copilot.lua",
116+
cmd = "Copilot",
117+
build = ":Copilot auth",
118+
event = "BufReadPost",
119+
opts = {
120+
suggestion = {
121+
keymap = {
122+
accept = false, -- handled by completion engine
123+
},
124+
},
125+
},
126+
specs = {
127+
{
128+
"AstroNvim/astrocore",
129+
opts = {
130+
options = {
131+
g = {
132+
-- set the ai_accept function
133+
ai_accept = function()
134+
if require("copilot.suggestion").is_visible() then
135+
require("copilot.suggestion").accept()
136+
return true
137+
end
138+
end,
139+
},
140+
},
141+
},
142+
},
143+
},
144+
}
145+
```
146+
113147
#### [codeium.nvim](https://github.com/Exafunction/codeium.nvim)
114148

149+
```lua title="lua/plugins/codeium.lua"
150+
return {
151+
"Exafunction/codeium.nvim",
152+
cmd = "Codeium",
153+
event = "InsertEnter",
154+
build = ":Codeium Auth",
155+
opts = {
156+
virtual_text = {
157+
key_bindings = {
158+
accept = false, -- handled by completion engine
159+
},
160+
},
161+
},
162+
specs = {
163+
{
164+
"AstroNvim/astrocore",
165+
opts = {
166+
options = {
167+
g = {
168+
-- set the ai_accept function
169+
ai_accept = function()
170+
if
171+
require("codeium.virtual_text").get_current_completion_item()
172+
then
173+
vim.api.nvim_input(require("codeium.virtual_text").accept())
174+
return true
175+
end
176+
end,
177+
},
178+
},
179+
},
180+
},
181+
},
182+
}
183+
```
184+
115185
#### [supermaven-nvim](https://github.com/supermaven-inc/supermaven-nvim)
186+
187+
```lua title="lua/plugins/supermaven.lua"
188+
return {
189+
"supermaven-inc/supermaven-nvim",
190+
event = "InsertEnter",
191+
cmd = { "SupermavenUseFree", "SupermavenUsePro" },
192+
opts = {
193+
keymaps = {
194+
accept_suggestion = nil, -- handled by completion engine
195+
},
196+
},
197+
specs = {
198+
{
199+
"AstroNvim/astrocore",
200+
opts = {
201+
options = {
202+
g = {
203+
-- set the ai_accept function
204+
ai_accept = function()
205+
local suggestion = require("supermaven-nvim.completion_preview")
206+
if suggestion.has_suggestion() then
207+
vim.schedule(function()
208+
suggestion.on_accept_suggestion()
209+
end)
210+
return true
211+
end
212+
end,
213+
},
214+
},
215+
},
216+
},
217+
},
218+
}
219+
```

0 commit comments

Comments
 (0)