Skip to content

Multiple Completion Providers #60

Open

Description

@eraldomarziano

Hi, I'm using your project and trying to implement a sort of assisted formula writer for a program I work on. There will be multiple sources for the suggestions, like the common formulas (if, then, etc), then some other word suggestions, and even some object from the file in the program itself.
Now, my question is: how can I distinguish the suggestions? In some other issue i saw that someone else managed to get a Visual Studio like symbol on the left of the suggestion name, but I can't find how to do that in documentation. If I create multiple autocompletions and install them in the same text area, if I enter a string that should trigger both of them only the first installed get fired, and the other gets fired only when i keep typing until no valid suggestion remains in the first provider.
Is there a way to set multiple autocompletion providers to work at the same time, maybe distinguishing between their suggestions? Or maybe to sort or filter someway the suggestions to separate by "origin"?

Activity

  1. self-assigned this
    on Oct 15, 2019
  2. bobbylight commented on Oct 15, 2019

    @bobbylight
    Owner

    Not sure I completely understand your question, but it sounds like you want to create multiple CompletionProviders and run them all when you need to display the completion popup, showing the aggregate of their completion suggestions. Is that right? If so then there's no built-in way to do that; you could do this yourself though by creating a "parent" delegating CompletionProvider implementation that runs multiple children and adds their results to a sorted list.

    As for how the completion list is rendered, a small example would be the HTML language support in the RSTALanguageSupport project. It implements a LanguageSupport instance for HTML, which is a higher-level construct over this AutoComplete library that you might not want/have to support, but it has nice features, especially if you're going to support > 1 language in an application.

    Anyway, look specifically at HtmlCellRenderer, which is the list cell renderer used by the autocompletion choices popup. You can use this as an example, and add yours by calling CompletionProvider.setListCellRenderer(). You can provide your own entirely custom ListCellRenderer or extend CompletionCellRenderer like the HTML example above does; CompletionCellRenderer has a lot of niceties if you use the built in Completion types, but it's not a requirement to use it.

    Hopefully that's enough to get started. Let me know if anything isn't clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions