Weird extmark placement for first placeholder
(this bug might be linked to #1019 (also with cmp))
With the following snippet:
snip("rbad", {desc = "bad local require"},
{ t"(manually) local ", i(1), t' = require"', i(2), t'"' }
)
Here I try to use the snippet 3 times:
- with direct expansion via
ls.expand()BUG - by first selecting something in
cmpbut still using a direct expansion vials.expand()ok - by first selecting the snippet result then
<C-y>ok
Also as you can see clearly on 2nd try, the cmp popup isn't hidden for some reason, it's quite annoying.
And when I try to close cmp's popup in my mappings (using if cmp.visible() then cmp.close() end before luasnip actions) I get a slightly different weird behavior:
Same steps as above, but the 2nd one is also buggy :disappointed:.
I'm really looking for a way to quickly expand snippets without getting weird cmp going in the way or having extmarks bugs.
I don't want to have to select the right result in cmp just to be able to expand without issues my 2 letters trigger ^^
Weird! I tried to reproduce it, and couldn't, at least with my current config.
https://github.com/L3MON4D3/LuaSnip/assets/41961280/d4a28a5f-d8eb-4a36-9c37-88a530720978
Here's my cmp-config, any major differences?
local cmp = require'cmp'
local types = require("cmp.types")
-- local session = require("session")
cmp.setup {
completion = {
autocomplete = {cmp.TriggerEvent.TextChanged},
completeopt = "menu,menuone,select"
},
snippet = {
expand = function(args)
-- local override_snip = session.lsp_override_snips[args.body]
-- if override_snip then
-- require("luasnip").snip_expand(override_snip)
-- else
require("luasnip").lsp_expand(args.body)
-- end
end,
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-y>'] = cmp.mapping.confirm(),
['<C-n>'] = cmp.mapping.select_next_item({ behavior = types.cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = types.cmp.SelectBehavior.Insert }),
},
sources = cmp.config.sources({
{name = "path"},
{name = "luasnip"}
}),
window = {
documentation = false,
},
experimental = {
native_menu = false,
ghost_text = true
},
}
Using cmp 5dce1b7, luasnip master.
Yeah that's what I thought, I'll try to repro with a minimal config later, probably this weekend.
Oh, one common cause of messed up extmarks are formatters, do you have one enabled?
No no formatter at the moment
It might be because I'm still using cmp's native menu.
Here is a reproduction script:
https://gist.github.com/bew/63bf7c3b01a32e85836e621a1b220e26
Ah, nice!
Seems like others have also run into this issue, #721 for example.
I don't know the internals of cmp well, but there are relatively few nvim_buf_set_text/nvim_buf_set_lines IIRC, maybe you could track what text they modify?
Note that I'm not using cmp to confirm & expand the snippet: I directly use <C-k> to expand, so cmp's text changes shouldn't be happening