GithubHelp home page GithubHelp logo

Comments (8)

ervandew avatar ervandew commented on August 26, 2024

Unfortunately, there is no current way in vim to detect when no completion results are found, so to automatically switch to an alternate completion method isn't currently possible.

What I do in the case you've described is to use a separate mapping, <c-space> in my case, to force keyword completion. Supertab includes a function that can be mapped to which handles cancelling the current completion mode and starting the specified one. Here is my mapping which I use to force the <c-p> keyword completion mode:
imap =SuperTabAlternateCompletion("c-p>")
Note: in my console, urxvt, I actually have to map to <nul> to get <c-space>
imap =SuperTabAlternateCompletion("c-p>")

from supertab.

milkypostman avatar milkypostman commented on August 26, 2024

Could you explain why the format of g:SuperTabContextDiscoverDiscovery is the way it is? It seems to me that you're just stripping out the from that anyways.

from supertab.

ervandew avatar ervandew commented on August 26, 2024

The idea with the format is that it allows you to define simple expressions to determine whether to turn a particular completion type on or not. The example in the docs uses the completefunc and omifunc options to basically say, if this option is set, enable this completion type, if not, go to the next one. However, instead of using those vim options you could use some other variable or even define a function to decide if a completion type should be chosen or not:

["MyFunc():<c-x><c-u>", ...]

So the goal is to provide the flexibility to hopefully do things I haven't thought of.

from supertab.

milkypostman avatar milkypostman commented on August 26, 2024

couldn't one write a completion function that calls multiple functions? I see that getting a completion is a two step process, determining where the completion starts and then returning a list of completions, but it should be somewhat easy to wrap them. I'll work on a function for this maybe it won't be so hard. I'll keep you informed.

from supertab.

ervandew avatar ervandew commented on August 26, 2024

The problem is that aside from user and omni completion, there is no function to call to get completion results. Maybe a custom function could call one of those and if no results are found then attempt to use feedkeys to fallback to something else. I'm not sure how vim will react to a feedkeys call at that point, and there are probably some subtle edge cases, but it may work.

Let me know how it goes.

from supertab.

hkhan avatar hkhan commented on August 26, 2024

I have also wanted to fall back to Keyword completion if no completions are found using omnicomplete.
Would it be possible to detect if no completion results are found using pumvisible()?

Thanks

from supertab.

ervandew avatar ervandew commented on August 26, 2024

As far as supertab is concerned, not really. All supertab does is intelligently decide which keys need to be sent to vim and then sends them. Supertab has no idea what the result of sending those keys was, nor does it have any hook into knowing when those keys have been fully processed to examine the result. I suppose supertab could tack on an additional <c-r>= expression to what is sent to vim to maybe get such a hook in place. Whether or not that would work, I'm not sure, but I'd try the wrapped ominfunc approach I described in my previous comment first.

When I get enough free time I'll see if I can put something together.

from supertab.

ervandew avatar ervandew commented on August 26, 2024

Latest couple[1] of commits[2] provide a new experimental way to
chain together one of omni/user completion with a fall back to any
other vim supplied completion key binding.

[1] 5904fa4
[2] 6982de1

from supertab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.