Skip to content
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

Migrate to a new Inline Completion API #244

Open
BarracudaPff opened this issue Mar 27, 2024 · 0 comments
Open

Migrate to a new Inline Completion API #244

BarracudaPff opened this issue Mar 27, 2024 · 0 comments

Comments

@BarracudaPff
Copy link

Hi!
For a long time, IntelliJ Platform lacked a built-in API to display inline completion (aka gray text completion). As a result, many plugins, including CodeGeeX, implemented it from scratch. In the latest 2023.3 release, the IntelliJ platform added an API for inline completion.

This new API allows developers to design plugins that enable inline completion, simplifying the process considerably. The primary benefit of this new API is that it enables multiple plugins to operate simultaneously, effectively enhancing overall system integration and compatibility.

The new built-in API is not compatible with implementations of other plugins, potentially causing two independent gray texts within the editor. We kindly invite you to explore the possibility of integrating our new API into your plugin at your earliest convenience. Your collaboration is crucial in achieving better synchronization between plugins for inline completion with the IntelliJ platform, thereby boosting the overall user experience.

Should you encounter any limitations or require additional features, please do not hesitate to let us know. We’re committed to ensuring this new API meets your requirements and improves the overall IntelliJ environment.

Here is our issue tracker.

Please migrate to the new API, you can find the entry points below:

  • The API is located in the package com.intellij.codeInsight.inline.completion.

  • The InlineCompletionProvider is the main class responsible for providing inline completion suggestions. It responds to various events, and for each one, it indicates whether it is ready to provide any suggestions for that event. There are default events: typing, changes in lookup, and direct call. If you require more events, you can create your own. There is a version of the provider that uses delayed execution to avoid wasting resources on non-meaningful user inputs.

  • For lower-level interaction, there's the InlineCompletionHandler. You can attach your listeners to it in order to monitor what happens with the suggestions generated. Furthermore, you can send your custom events via InlineCompletionHandler.

  • The provider yields a flow of InlineCompletionElements that need to be rendered. Because the flow is lazy, this API supports data streaming, allowing for the gradual appearance of elements. Each element features an interface that demonstrates how to render it. The standard rendering of gray text is already provided. Should you require more complex elements, you can easily achieve this by extending the interface as described above.

  • The API also supports reaction to overtyping, meaning instances where the user types characters that match the suggestion. Additionally, you can add a custom insertion handler if you need to perform specific actions following element insertion.

  • For now, support for only one suggestion per event is available out of the box. Support for multiple suggestions will be enabled in the upcoming 2024.1 release. However, you can also incorporate this functionality through custom events as detailed earlier.

It should cover all your features with current implementation and even more.

Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant