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
Feature Request: Allow Filtering yasnippet completions when triggered by trigger sequence #840
Comments
|
Also note, using |
|
Try this: (defun company-yasnippet-unless-member-access (command &optional arg &rest ignore)
(if (eq command 'prefix)
(let ((prefix (company-yasnippet 'prefix)))
(and prefix
(save-excursion
(forward-char (- (length prefix)))
(not (looking-back (rx (or "." "->")) (line-beginning-position))))
prefix))
(company-yasnippet command arg)))And use this backend instead of |
|
That works great, thanks! Some questions: Is there a way to automatically use all the "triggers" specified for that particular language? Seems like different languages are going to have their particular cases when it's not appropriate to show snippets... For example, here's some additional cases for c++ where snippets probably shouldn't be shown:
Also, is this something that would be provided with company-yasnippet (and have the lookback chars be a defcustom, or language specific alist, etc...), or should I just put it in my local config? |
If there were an existing convention to specify them in language mode definitions, we could. I'm not aware of one, though.
This, at least for now. And I also think it works better as a wrapper backend, because whether we want to avoid snippets after trigger characters depends on the presence of other backends (and whether they provide snippets for completions). |
|
Sounds good, and thanks, it works much better. I'll leave it up to you whether you want to close this issue or not... |
|
Let's leave it open for now. |
…eparately This should help with #1398, #641, #553, #485, #1147, #840 With some of the above already closed, and some describing more serious scenarios than others. Anyway, this is a halfway step to dropping framework-level caching (or moving it to backends). For now this seems like an adequate solution, given that the most "heavy" backend these days is `company-capf`, which disables caching already. Though `company-dabbrev-code` is a close next.
…eparately (#1405) * company--multi-backend-adapter: Consider min prefix in 'candidates' separately This should help with #1398, #641, #553, #485, #1147, #840 With some of the above already closed, and some describing more serious scenarios than others. Anyway, this is a halfway step to dropping framework-level caching (or moving it to backends). For now this seems like an adequate solution (resetting the cache sometimes when the new chars are typed), given that the most "heavy" backend these days is `company-capf`, which disables caching already. Though `company-dabbrev-code` is a close next. Uses new semi-private backend action called 'set-min-prefix', to keep the merging function's backward compatibility, for the sake of external callers.
|
Check out the latest master, the behavior should be improved. |
This seems somewhat related to #485 , but the idea is that I'm grouping company-lsp/cquery (c++) and company-yasnippet together via:
Completing without input (prefix) shows all globals and snippets as expected.
But, when I have completions from a trigger character ('.' or '->') then all the snippets show up in the completions, which is never desired behavior in this setup.
It would be great to only show snippets in completions if completion list isn't triggered by a trigger sequence.
I've considered trying to set up
company-transformersto perform this filter, and maybe that's a way to implement this? Not sure...Thoughts?
The text was updated successfully, but these errors were encountered: