-
Notifications
You must be signed in to change notification settings - Fork 411
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
option to autocomplete your cursor's text on the first item too #1529
Comments
It seems dup of #1424 |
Sorry. I can't understand. I guess you should check the following two points.
set completeopt=menu,menuone,noselect |
@hrsh7th tried but doesn't seems to work, I have recorded a video showing the issue: https://youtu.be/awc4BjLwf9M |
What do you get the result with the followings?
|
It seems Vim completeopt menu behavior(manual completion). |
|
@Thanatermesis Could you try with |
I can't determine the root cause. Sorry. |
@Thanatermesis You should create the minimal |
Same issue, pressed Tab and the menu appears but my text is not replaced with the first result 🤔
Yes, I'm using the NvChad framework which already included nvim-cmp integrated, so maybe this can be an easy way to reproduce it (in a test environment, install NvChad in a single command, everything goes installed and nvim-cmp included, then change the trigger like "autocomplete = false" and add Tab to open the menu, just like in the video, and the bug should happen) |
Please don't use the plugin distribution for it. |
Could you try the following? require('cmp').setup {
completion = {
completeopt = 'menu,menuone,noselect'
}
} My nvim-cmp config does not reproduce this problem so I think you should raise issue for the nvchad side. |
There's a small screencast of all the process (installing the nvim NvChad framework from zero, and without extra plugins) from scratch, the modifications I did to disable the autopopup, and showing the issue, including a "set" of the parameters you told me, in a strange way even if I set the values you said, it seems like when running nvim they are replaced by "menu,preview" 🤔
Maybe @siduck knows why the value of completeopt is replaced Note: the bug is on the minute 5:00, already included on the link: |
just override nvim-cmp opts in your custom plugins |
@siduck yes that's what I do but it doesn't seems to take effect, I changed it to "menu,menuone,noselect" but it doesn't gets static (as you can see in the video), on the other hand I set it manually with :set to that value but the bug stills present 🤔 |
works here tho simplescreenrecorder-2023-04-29_06.27.25.mp4{
"hrsh7th/nvim-cmp",
opts = {
completion = {
completeopt = "menu,menuone,noselect",
},
},
}, |
@siduck Mmmh, I don't think so, the issue is that when the menu is set to not automatically popup all the time but with manually triggering it, so by pressing tab, the text is not autocompleted to the first result, only to the next ones This means, adding "autocomplete = false," on the completion section, and in the TAB mapping, changing the fallback line to "cmp.complete()" More details on the first post and a demo on the video: https://youtu.be/awc4BjLwf9M |
Ok so I think this code made it finally working, so first I need to have the entry to Then, I need to replace the cmp.complete({ behavior = cmp.SelectBehavior.Select })
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert }) This looks very good! the menu only appears when I press Tab, at the same time my text has the added keyword, if I press "space" the keyword is kept (used) on my line, if i want to open a snippet I press "enter"... same behaviour with the menu automatically showing up (which is annoying for me at the moment because it doesn't lets me to use Copilot as I mentioned here) |
For anyone coming across this from google, you can improve it a little bit more by conditionally running complete based on whether the menu is already open. heres the full example I'm using right now: ["<C-k>"] = cmp.mapping(function(fallback)
if not cmp.visible() then
cmp.complete({ behavior = cmp.SelectBehavior.Select })
end
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
end, { 'i', 's' }),
["<C-j>"] = cmp.mapping(function(fallback)
if not cmp.visible() then
cmp.complete({ behavior = cmp.SelectBehavior.Select })
end
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
end, { 'i', 's' }), |
I have the "autocomplete = false", so menu only opens when I hit "tab"
If you see, when the second item is selected, the text in the cursor is filled up (similar to ghost_text), but this doesn't happens with the first item
In the normal behaviour that's somewhat normal, where the menu always opens with the first item preselected, but only when you scroll to the next option your cursor's text is modified, the issue is that the first item is not really preselected just hilighted, but when you trigger cmp.complete(), the first item should be selected in the same way the next ones are
The text was updated successfully, but these errors were encountered: