sly icon indicating copy to clipboard operation
sly copied to clipboard

How to make company-backends work with sly?

Open zwpdbh opened this issue 4 years ago • 2 comments

Sly works great with company by default. The company could return the candidates by their relevance. But sometimes, there are some words/symbols I just typed in the source code (have not been evaluated) could not be popup as candidate in company.

For example, in the process of defining a function, there must be some variables. And I want company to complete those variables. So, I setup the company-backends as: ((company-capf company-bbdb company-dabbrev-code)).

I found two problem related with it:

  1. the company-backends doesn't work, it doesn't solve the original problem. Auto-completion still only works on symbols has been compiled/evaluated.
  2. the company-backends somehow mess up the relevance of candidates. I am not sure if it is related with the issue: https://github.com/joaotavora/sly/issues/260

So, is there a way to set company-backends with sly. Like, in SLIME, we could set the backends as: ((company-slime company-capf company-bbdb company-dabbrev-code)), then the auto-completion will give both common-lisp symbols and any symbols in current editing buffer.

Thanks a lot for your great work.

zwpdbh avatar Jun 16 '20 00:06 zwpdbh

So, I setup the company-backends as: ((company-capf company-bbdb company-dabbrev-code)).

I'm not a company expert, I leave company-backends alone. As far as I know, SLY's addition to completion-at-point-functions, which includes a few :company-specific cookies, doesn't do anything extraordinary that would prevent the composition of results from various sources, as you desire.

I think I understand your request, but I would say this is a company-specific issue that I'm not best placed to debug. Let's hail @dgutov here, perhaps he can assist.

I am not sure if it is related with the issue: #260

Yes, it seems so. I've closed that one (that I had paid no attention to) and following up here.

Thanks a lot for your great work.

You're welcome.

On a tangent, I would say that I one should be able to do what you want strictly with completion-at-point-functions (i.e. have some bbdb or dabbrev-specific function there). Then company-capf (or some other tooltip) would inquire and compose the results produced by the members of completion-at-point-functions. In that idealized scenario, you would not have to worry about company-backends at all. However, again, this is a tangent (one I suspect is contentious for @dgutov) it has no direct bearing on what you're trying to achieve right now.

joaotavora avatar Jun 16 '20 09:06 joaotavora

On a tangent, I would say that I one should be able to do what you want strictly with completion-at-point-functions (i.e. have some bbdb or dabbrev-specific function there)

I would hope so. So far this train has seen very little movement, however. And not just because there's no dabbrev-specific completion function (porting it over would be easy).

As far as I know, SLY's addition to completion-at-point-functions, which includes a few :company-specific cookies, doesn't do anything extraordinary that would prevent the composition of results from various sources, as you desire.

That agrees with my understanding. However, there is one thing that backends in a group have to agree with: the returned value of the prefix. So if Sly's completion function indicated different values of prefix (e.g. longer or shorter strings), the other backends would not be used.

@zwpdbh What does M-x company-diag say, when called in circumstances in question?

dgutov avatar Jun 16 '20 23:06 dgutov