tabby
tabby copied to clipboard
Migration to new IntelliJ platform API for inline completion
Dear TabbyML team,
I'd like to ask you about your plugin for the IntelliJ Platform that provides inline completion (i.e. gray text completion or ghost completion).
We have noticed that many plugins with similar functionalities make use of their own unique APIs. While this does indeed facilitate a degree of flexibility and customization, it unfortunately means that these plugins cannot be used simultaneously. In addition, as of version 2023.3, these functionalities are included directly within our built-in plugins.
Because we understand the complexity of the situation, our team has developed an API within the IntelliJ platform. 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.
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.
The entry points for our new API are as follows:
-
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. We plan to enable support for multiple suggestions in either the upcoming minor releases of 2023.3 or in 2024.1. However, you also have the option to incorporate this functionality through custom events as detailed earlier. Here is an example of support for a “multiple suggestions” inline completion provider.
We firmly believe that using our API for inline completion will collectively enhance the user experience. Thank you for your attention to this matter, and we look forward to your response. Feel free to ask anything about the API.
LSP 3.18 (upcoming) provides an API for inline completions (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocument_inlineCompletion).
TabbyAgent being based on LSP could use that AFAIU. Will IntelliJ support this as well?