blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

Accept by word / line

Open meijieru opened this issue 8 months ago • 6 comments

Feature Description

Thanks for this awesome plugin!

From https://github.com/fang2hou/blink-copilot/issues/13,

Overall, it’s been incredibly helpful. One feature that could improve the experience further is the ability to accept completions per word or line instead of the entire block, especially when dealing with ai suggestions. For example, sometimes a suggestion works well for part of the code but not the rest, and having granular control (like copilot.lua’s partial acceptance) would streamline workflows. Would this be feasible to implement?

meijieru avatar Mar 26 '25 02:03 meijieru

What means the word? The word is non space characters or \w characters?

Shougo avatar Mar 26 '25 04:03 Shougo

What means the word? The word is non space characters or \w characters?

Both make sense for me. Maybe as an option?

meijieru avatar Mar 26 '25 04:03 meijieru

Or it may be another key map.

accept, accept_word, accept_non_spaces, accept_line

Overall, it’s been incredibly helpful. One feature that could improve the experience further is the ability to accept completions per word or line instead of the entire block, especially when dealing with ai suggestions. For example, sometimes a suggestion works well for part of the code but not the rest, and having granular control (like copilot.lua’s partial acceptance) would streamline workflows. Would this be feasible to implement?

I think it would be easier to understand with a concrete example.

Shougo avatar Mar 26 '25 04:03 Shougo

Image

An example of Copilot's suggestions: I only want the suggestion for the first line but ignore the rest. The 'Accept line' feature would be the only way to do this. This is especially useful when dealing with longer AI-generated suggestions.

meijieru avatar Mar 27 '25 03:03 meijieru

For anyone looking to implement this, I would start by adding a function to https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/lib/text_edits.lua or under accept/* which transforms the newText to only include one line or word (similar "by word" implementation here, maybe there can be some reuse).

Then the accept function would take some argument which enables the by word or by line behavior. And the relevant command can be added here https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/init.lua#L126

saghen avatar Mar 31 '25 02:03 saghen

I'd be very interested in this also. I use similar functionality in supermaven-nvim at the moment.

DaniBedz avatar Jul 16 '25 14:07 DaniBedz