Skip to content

Conversation

@franchioping
Copy link

As described in #6, regex snippets show up as their expression, adding a lot of bloat to the completion menu
With this pull request, you can manually edit the label through the config, like this

          { name = 'luasnip', opts = { label_aliases = {
            ['(?<!\\\\)(sec)'] = 'sec',
          } } },

And now, the snippet will show up as 'sec', but still match as '(?<!\\\\)(sec)'

Working example below (list of snippets on the right, has nothing to do with the plugin configuration)

image

@bew
Copy link

bew commented Jan 22, 2025

Instead of having to configure the completion source, I think ot would be much nicer to add a label to each snippet that needs a custom one. This way at least you don't have to duplicate the trigger

@saadparwaiz1
Copy link
Owner

I agree with @bew here. I don't think this change should go in as that'll mean duplicating your snippet in two places. LuaSnip and then cmp_luasnip

@franchioping
Copy link
Author

Im not increadibly familiar with luasnips, so im not sure how it would be structured/if it would need some new feature, but I do agree this isn't optimal, and more like a patched-on fix
I'll look into how the configuration would be through luasnips

@franchioping
Copy link
Author

Is a function that takes a snippet and an alias as an input and returns the snippet a viable solution? so a snippet file would look something like this.

return {
  aliasfunc(s(<configure snippet here>), "alias")
}

the function would add the alias, in the same format as previously suggested, and simply return the snippet so it can still be used like normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants