Open haoming-li-ling opened 2 years ago
Hmm, probably because we nvim_buf_set_text
on the line where nvim-cmp
is currently operating..
I think your best bet to get this fixed is creating a minimal example that does not depend on luasnip, and opening an issue in nvim-cmp
with that, there's nothing (I think) we can do about this, here :/
For that minimal example, you could try registering an autocommand on TextChangedI
, which just inserts some characters somewhere in the line (the beginning could be easiest).
I'm also facing somewhat related issue, where I have a snippet like this:
s(
{ trig = "import", name = "Import Name" },
fmt('import {} from "{}";', {
c(2, {
d(nil, function(args)
local specifier = args[1][1]
local import = utils.to_pascal_case(specifier)
return sn(nil, { i(1, import) })
end, { 1 }),
sn(nil, { t("{ "), i(1, "named import"), t(" }") }),
sn(nil, { t("* as "), i(1, "namespace import") }),
}),
i(1, "specifier"),
})
),
And while the cmp menu is visible I try to select a completion item by <Tab>
-ing, it then jumps the cursor to jump index 2
(the choice nodes here) instead of selecting the next completion item.
I was able to reproduce it using kickstart.nvim
with the above snippet.
If I have a snippet that contains a function/dynamic node that depends on the input to an insert node on the same line, e.g.,
i(1), d(2, function(args) ... end, {1})
, if I setupdate_events = "TextChanged,TextChangedI"
, then nvim-cmp will fail to properly provide completion items when I am in thei(1)
node. Nvim-cmp will refresh its completion items each time I press<c-n>
or<c-p>
to select (and insert) the next or previous items, which is unusable.Even if I use nvim-cmp's
SelectBebavhior.Select
, that is, the current autocomplete selection is not automatically inserted at the cursor but merely selected, nvim-cmp stills provides problematic completion items (only items from the buffer source are provided; nothing else is).Note that if the dynamic/function node is on a different line than the one where the insert node it depends on is, nvim-cmp works properly with
update_events
set to"TextChanged,TextChangedI"
, regardless of theSelectBebavior
setting.I don't know if this is a luasnip or a nvim-cmp problem though...