feat(supermaven): support word-completion

The supermaven-plugin supports partial completion, which is essentially
expanding the next word. Configuration is extended to allow
word-expansion on S-Tab with blink.
This commit is contained in:
Dennis Frommknecht 2025-01-27 18:31:23 +01:00
parent 83bf6360a1
commit 17ee28dc4a
2 changed files with 18 additions and 8 deletions

View file

@ -20,16 +20,22 @@ return {
"supermaven-inc/supermaven-nvim",
opts = function()
require("supermaven-nvim.completion_preview").suggestion_group = "SupermavenSuggestion"
LazyVim.cmp.actions.ai_accept = function()
local suggestion = require("supermaven-nvim.completion_preview")
if suggestion.has_suggestion() then
LazyVim.create_undo()
vim.schedule(function()
suggestion.on_accept_suggestion()
end)
return true
local ai_accept = function(partial)
return function()
local suggestion = require("supermaven-nvim.completion_preview")
if suggestion.has_suggestion() then
LazyVim.create_undo()
vim.schedule(function()
suggestion.on_accept_suggestion(partial)
end)
return true
end
end
end
LazyVim.cmp.actions.ai_accept = ai_accept(false)
LazyVim.cmp.actions.ai_accept_word = ai_accept(true)
end,
},

View file

@ -85,6 +85,10 @@ return {
keymap = {
preset = "enter",
["<C-y>"] = { "select_and_accept" },
["<S-Tab>"] = {
LazyVim.cmp.map({ "snippet_backward", "ai_accept_word" }),
"fallback",
},
},
},
---@param opts blink.cmp.Config | { sources: { compat: string[] } }