Ale: Add a function for use with `omnifunc`

Created on 8 Feb 2019  Â·  10Comments  Â·  Source: dense-analysis/ale

ALE is mainly asynchronous, but it would be convenient to have a synchronous completion function that works with omnifunc to allow ALE to work with other completion plugins (that chain completion functions until a result is found).

Example plugins:

enhancement

Most helpful comment

I fixed the filtering issue, and this has been implemented now. You can use it like so, where you could use automatic completion before.

set omnifunc=ale#completion#OmniFunc

All 10 comments

This is planned. I edited the title because it's not possible for it to be synchronous, and that's not desirable. The function would do what automatic completion does now, only triggered by the omni-complete keybind. It may have to be the same function called twice to work.

it is desirable to have omnifunc sync as this is the only way to integrate it with mucomplete and others from the list. I think it's doable via:

let results = GetResults()
while results is v:null
  sleep 20m
  let results = GetResults()
endwhile

mucomplete doesn't offer any asynchronous completion support, so I have no interest in supporting it.

The omnifunc function described here is purely for use with ALE alone.

mucomplete doesn't offer any asynchronous completion support, so I have no interest in supporting it.

From UX point of view completion should never be async, you should get your results instantly instead. If it's not instant you should raise an issue with your LSP server. All completion engines for vim which I've tried do not provide very good UX — usually I see jumpy completion lists which makes it hard to select the correct option from them.

Locking the user's entire editor for a long period of time to deliver completions results is bad UX, and sleeping a loop in a single threaded environment is bad programming. I have no interest in implementing synchronous tasks as part of a plugin with "asynchronous" in the name.

I think that in order to play well with chain-completion plugins it would have to be synchronous. They usually work by trying one type of completion, and if no results are returned try the next type of completion, until a result is found.

I totally agree that blocking the editor is undesirable, because some LSPs can take a bit of time to return results, but I don't know how else to make it flow well with other plugins.

Another thing to consider would be that with features that run by itself, like automatic linting, it's important not to block the user. However, if a user initiates a command, like a fixer or LSP action, they're waiting for that to respond before they continue.

Okay, in that case the sleep loop suggested by @andreypopp will probably be best.

I have created a branch with a function for this. It needs some testing and documentation before it will be ready. One thing it needs the most is that the results in the menu need to be filtered by the text you've already typed in. If you have foo.ba it can suggest foo.xyz, based on getting completion results for anything after foo..

I fixed the filtering issue, and this has been implemented now. You can use it like so, where you could use automatic completion before.

set omnifunc=ale#completion#OmniFunc
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chauncey-garrett picture chauncey-garrett  Â·  3Comments

trevordmiller picture trevordmiller  Â·  3Comments

sodiumjoe picture sodiumjoe  Â·  4Comments

amerov picture amerov  Â·  4Comments

plexigras picture plexigras  Â·  3Comments