From 977f625e5dec9beaa15a6eea0c5398eaca95ee82 Mon Sep 17 00:00:00 2001 From: Simon Lasbrugnas Date: Wed, 25 Jun 2025 17:06:51 +0200 Subject: [PATCH] feat(supermaven): add on-demand autocompletion Removes inline text suggestion and binds to autocomplete. Under the hood it activates inline text suggestion, accept the suggestion and then disable it again. It removes the noise of AI text suggestions while allowing me to take advantage of it when it's useful. --- lua/custom/plugins/supermaven.lua | 10 +++------- lua/custom/supermaven.lua | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 lua/custom/supermaven.lua diff --git a/lua/custom/plugins/supermaven.lua b/lua/custom/plugins/supermaven.lua index ff78ebc..481743b 100644 --- a/lua/custom/plugins/supermaven.lua +++ b/lua/custom/plugins/supermaven.lua @@ -1,10 +1,6 @@ return { "supermaven-inc/supermaven-nvim", - opts = { - keymaps = { - accept_suggestion = "", - clear_suggestion = "", - accept_word = "", - }, - }, + config = function() + require("custom.supermaven") + end } diff --git a/lua/custom/supermaven.lua b/lua/custom/supermaven.lua new file mode 100644 index 0000000..a390699 --- /dev/null +++ b/lua/custom/supermaven.lua @@ -0,0 +1,24 @@ +require("supermaven-nvim").setup({ + disable_keymaps = true, + disable_inline_completion = true, + log_level = "info", +}) + +-- Supermaven on-demand configuration +local suggestion = require('supermaven-nvim.completion_preview') + +local function on_demand_complete() + vim.g.supermaven_inline_completion_enabled = true + + vim.schedule(function() + if suggestion.has_suggestion() then + suggestion.on_accept_suggestion() + end + + vim.g.supermaven_inline_completion_enabled = false + end) + + return "" +end + +vim.keymap.set('i', '', on_demand_complete, { expr = true, silent = true, desc = "On-demand Supermaven completion" })