-
Notifications
You must be signed in to change notification settings - Fork 233
Allow auto-inserting completion items #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If I understand correctly, The idea is that Example, If I select |
I don't think so. I believie it is about replicating this behaviour from nvim-cmp
|
Correct. I think it could be a bit better though. In my original post I mentioned selecting an item (inserting the suggestion automatically) and closing the completion menu (by typing a It would still be a special case for snippets though. Even if we insert the whole snippets on selection, which I'm not sure would be desirable at all, it probably wouldn't be desired to trigger the snippet behavior (cycling through the placeholders of the template) after inserting a non completable character. I've been working on implementing this today and I think got something that almost works. I'll post a draft PR after #24 is merged. |
Ok, I was thinking of a feature from coq_nvim. I've implemented it by binding every non special key in insert mode but it's kinda hacky, + It might impact performance. |
Currently the only way to actually insert text from the selected completion item is to "accept" it. It requires first using keymaps to select the right item, and then use another keymap to accept it. I propose adding a new
auto_insert
boolean to the config, that iftrue
will have this behavior:select_next
andselect_prev
, its text will be automatically inserted, if the item is not a snippetIt would need to be coupled with #24 so that we can avoid inserting the first item every time the completion menu appears, and instead only insert it when deliberately starting the selection.
This allows the following workflow:
(
for example.Of course if we intend to use a snippet, use an argument-filling snippet-like helper (not sure if that's implemented yet?), or benefit from auto-importing, we can optionally use the
accept
keymap.I've tried to implement this myself, however it is a little bit more complicated than I expected. I initially thought it'd be just a matter of calling:
blink.cmp/lua/blink/cmp/accept/init.lua
Line 27 in 8632278
without the rest of the
accept
function, but it messes up with the auto commands set up by:blink.cmp/lua/blink/cmp/trigger/completion.lua
Line 21 in 8632278
so we'd probably need to add some sort of state to identify whether the change was the result of a selection or an "accept".
The text was updated successfully, but these errors were encountered: