Skip to content

Add a way to manually configure labels #66

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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