Add native GitHub Copilot inline completions#2182
Draft
anxkhn wants to merge 1 commit into
Draft
Conversation
Integrate the GitHub Copilot language server to provide AI inline completions (ghost text) in the editor, building on the inline-suggestion primitive in CodeEditTextView and the InlineCompletionDelegate seam in CodeEditSourceEditor. New Features/Copilot group: - CopilotService: @mainactor ObservableObject singleton that owns the language-server process and lifecycle, publishes auth state (signedOut / awaitingDeviceCode / signedIn / error) and a busy flag, and brokers document sync and inline-completion requests. Resolves the binary from settings or PATH. - CopilotClient: raw JSON-RPC transport over a framed JSONRPCSession that drives Copilot's custom methods (initialize, signIn, checkStatus, textDocument/inlineCompletion, telemetry) and answers server-to-client requests (workspace/configuration, workDoneProgress/create, showDocument) plus didChangeStatus/v2. - CopilotProtocol: Codable param/result types for the custom methods. - CopilotInlineCompletionProvider: implements InlineCompletionDelegate, syncs the document, maps the cursor to an LSP position, and adapts server items to ghost text (prefix-stripping, newline normalization). - CopilotDocumentObjects: per-document bundle that owns the provider so the controller's weak delegate reference survives. Wire-up: - Register CopilotService alongside LSPService in CodeEditApp. - Add a Copilot settings page (enable toggle, language-server path, device-flow sign-in/out with live status) and SettingsData/SettingsPage entries. - Add a status bar item reflecting Copilot state. - Pass the inline completion delegate from CodeFileView when enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds native GitHub Copilot inline completions to CodeEdit. As you type, the editor shows AI ghost text suggestions and accepts them with Tab. This is the app-level integration on top of the inline suggestion rendering primitive (
CodeEditTextView) and the inline completion coordination layer (CodeEditSourceEditor).What's added:
CopilotClient/CopilotService/CopilotProtocol: launches and talks to the officialcopilot-language-serverover LSP, with device-flow sign-in, status, and document sync.CopilotInlineCompletionProvider: a per-documentInlineCompletionDelegatethat maps the caret to an LSP position, requests completions, strips already-typed prefixes, and adapts results into the editor's ghost-text model. Suggestions render via theCodeEditTextViewoverlay and never mutate the document until accepted.CopilotBinaryResolver: locatescopilot-language-server(explicit path,PATH, or common install dirs) and builds a launch environment that can findnode, including nvm installs, since the server is a Node script.CodeFileDocument/CodeFileViewto attach the provider per open document.Related Issues
Checklist
Screenshots
I will attach a screen recording of the device-flow sign-in and inline ghost text (request, multi-line preview, and Tab to accept).
Testing
copilot-language-server: device-flow sign-in, inline ghost text as you type, and Tab to accept.