-
Notifications
You must be signed in to change notification settings - Fork 7
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
Use luasnip api for getting choice-docstrings #1
base: master
Are you sure you want to change the base?
Conversation
@doxnit Please merge asap! |
You can also get my changes right away by using |
@L3MON4D3 I know but it would be best to have it in the mainstream branch instead. |
Ah okay, I misunderstood you😅 |
So far, so good... I think we need a small fix: the choice has to be rendered when user choses it.. lua-snip-choice-fix-by-L3MON4D3.mov |
@L3MON4D3 I think previous, OOP-oriented api of the LuaSnip was much better.... I wonder when this has changed. |
I removed that, because it seemed to mess up the snippet a bit. I'll see if I can add it back in while avoiding those issues
Unfortunately, those methods were never public api, and I don't think they even used to work in all cases :/ |
@L3MON4D3 Totally understandable. Thanks for all the hardwork. Looking forward for a merge! |
Hi, For some reason, I cannot get this plugin to work? Choice selection works fine when using I am using using snippets loaded from VS-code style snippet files if that matters. |
@chrisgrieser Your question is compeletly unrelated and should be referred to the You have to properly configure mapping = {
["<Up>"] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(-1)
if cmp.visible() then
-- Instead of inserting, just focus a visual dropdown item
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
return
end
end
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
else
fallback()
end
end, { "i", "s", "c" }),
["<Down>"] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(1)
if cmp.visible() then
-- Instead of inserting, just select a visual dropdown item
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
return
end
end
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
else
fallback()
end
end, { "i", "s", "c" }),
} |
I have cmp working correctly for 10+ sources – cmp-luasnip-choice is the only one that does not work. |
@chrisgrieser It works for me as it's properly configured. |
I'm also having issues with both versions of this plugin, and agree with Chris in that the problem seems to be with this plugin.
For example, if I'm on a choice-node with the choices "black", "white", "blue", "orange", and type the character 'b', I would expect to get the results: "blue", "black", "white", and "orange", in this order, in the nvim-cmp completion popup menu. (without explicitly having to call |
Sorry, I'm really not interested in maintaining this :/ |
Fixed the auto-open/autocompletion issue by changing this: function M.source:get_keyword_pattern()
return ''
end to this: function M.source:get_keyword_pattern()
return "\\%([^[:alnum:][:blank:]]\\|\\w\\+\\)"
end which I fetched from the Some other pattern might work there too I suppose, but I'm not too good at this regex stuff, so I'll take what works. |
For some reason, there is never a choice node active. Tried to do some minor debugging. But even while the EDIT: EDIT2: |
@Aumnescio your trigger should not be necessary as completion gets called manually when entering a choice node. So this simply doesn't matter. It is also not necessary to register the |
@L3MON4D3 is it possible to have snippet descriptions for choice nodes? Like you can provide the |
Hey!
I noticed (due to an issue in luasnip) that first of all, this plugin exists, nice work! and that it's using some not-so-safe api of luasnip.
This change mostly uses
ls.get_current_choices
to get the string-descriptions of the choices, which should be more stable than the current approach.Also, I've set the text inserted by nvim-cmp when hovering over any of the choices to
""
, I've encountered some issues when this was long text (for example with this snippet) (feel free to have me drop this one if you don't like it though :) )