-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add options to filter candidate returned from server. #86
Conversation
A new custom option `company-lsp-filter-candidates` is added to allow customizing whether or not to filter candidates when `company-lsp-cache-candidates` is set to nil. The option can be either set to a boolean, or an alist for configuring it on a per-server basis. When `company-lsp-cache-candidates` is set to non-nil values, this option doesn't affect the filtering behavior since candidates are always filtered in this case. This should fix #79.
Afaik company itself could do the filtering if you return 'no-cache nil. It seems to me that In lsp-mode case we need to return nil when the server has returned isIncomplete=false which pretty much means "you could do the rest of the filtering client side" (cc @dgutov) |
Only if you do prefix matching. Meaning, fuzzy matching won't work this way. |
We do return It's unclear how to handle incomplete candidates here. We shouldn't let company to cache incomplete candidates here. @dgutov How does company behave if for prefix="foo" |
I tried out your PR, confirmed it works. I didn't set any option like |
IMO we should do it only if isIncomplete is nil since the server might have returned partial results. From what I can see, VScode handles isIncomplete the way I have described it in the previous comment and so it makes sense to have this as a default behaviour for all of the servers(having company-lsp-filter-candidates = t). This approach has also a performance benefit. You may ignore my concern about company-lsp doing the filtering since it seems like it doesn't matter much whether the filtering is performed in company or company-lsp(if it is in company-lsp we may implement flx matching as per your comment). Example(using vscode and jdtls). The first screenshot is if I have invoked manually the completion, the second one is if I have typed
|
It does. When the cache is cleared, it uses the previous value of prefix. But you should probably do just do all cache management in the backend. The logic will be easier to follow, for one thing. |
@yyoncho If you set Now, let me describe why the other two options,
|
@dgutov What's the best practice in invalidating caches? I'm listening to Lines 311 to 313 in 4eb6949
And invalidating and removing when the hooks are called: Lines 320 to 324 in 4eb6949
However from time to time the caches are not invalidated while the clean up function is removed from the hooks. I can always listen to the hooks and not remove them when invalidating caches. This will cause the function be invoked when other backends are used though. I wonder if there are better way to trigger cleanup function only when the company-lsp backend is used and finished? |
@tigersoldier I am rooting for caching since it looks slicker when e. g. there is no flickering, it is instant. What you are saying make sense though. I guess once you implement flx matching we may rely more on client-side filtering, right? For me this seems to be the best solution, what do you think? |
@yyoncho I do think auto caching provides best out-of-box user experience, even without flx matching (which may not come any time soon). Just need to fix the annoying bug before making it the default option. Before that, let's have this work around submitted for the current default, no caching. |
Starting with company-mode 0.9.9, you can replace them with
That's one option. If the cache is a global lsp-related variable, other backends will probably not mind anyway.
Have you figured out why this is not the case? Since you're using the local values of the hooks, and populating them from the backend, it seems like it should work. |
Sorry to revive this old thread. I'm using
In other words set prefix matching and don't cache candidates. Anything else seems to give me way too much. |
A new custom option
company-lsp-filter-candidates
is added to allowcustomizing whether or not to filter candidates when
company-lsp-cache-candidates
is set to nil. The option can be either set to aboolean, or an alist for configuring it on a per-server basis.
When
company-lsp-cache-candidates
is set to non-nil values, this optiondoesn't affect the filtering behavior since candidates are always filtered in
this case.
This should fix #79.