Add VS Code-style autocomplete with keyword suggestions#9
Merged
Conversation
Enable CodeMirror's completion UI in the editable setup (read-only previews stay off) and wire per-language sources: - JS/TS/JSX/TSX: keep the built-in keyword/local completions and add scopeCompletionSource(globalThis) so browser globals and their members (console.log, JSON.parse…) complete like in VS Code. - HTML/CSS/Python/SQL: their lang packages already ship completion sources; enabling the UI is enough. - Languages without a completion source (legacy stream modes plus bare grammars like Java/C++/PHP/JSON/XML): a fallback source merges word-based suggestions from the document with curated per-language keyword lists, deduplicating words already offered as keywords. - Markdown prose stays quiet; fenced code blocks complete via their nested language. Style the suggest popup after VS Code (panel tokens, blue matched text, per-type symbol icon colors) in both themes, and swap the default key-emoji keyword glyph for a plain marker. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QAjpJTH4WCmyRXkMWLSosz
Contributor
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
klipcode | dce30b7 | Commit Preview URL Branch Preview URL |
Jul 02 2026, 08:57 AM |
…plete-approach-p5xnwq # Conflicts: # src/components/Editor/Editor.tsx
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.
Implements autocomplete for languages that lack built-in completion sources, providing word-based suggestions merged with curated keyword lists styled to match VS Code's suggest widget.
Summary
This PR adds intelligent autocomplete to the editor for 24 languages (Java, C/C++, PHP, Go, Rust, etc.) that either use legacy grammar modes or don't ship with completion sources. The implementation combines document word suggestions with language-specific keyword lists, styled with a VS Code-inspired popup design.
Key Changes
New completion module (
src/components/Editor/completions.ts):wordAndKeywordCompletion(): Merges CodeMirror's word-based completions with optional keyword lists, deduplicating keywords that appear in the documentLANGUAGE_KEYWORDS: Curated keyword lists for 24 languages (reserved words, builtins, common types/functions)Editor integration (
src/components/Editor/Editor.tsx):loadJavaScript()helper to add scope-aware completions viascopeCompletionSource(globalThis)FALLBACK_COMPLETION_LANGUAGESset to identify languages needing the fallback completion sourceautocompletion: falsetotrue)Styling (
src/app/globals.css):Tests (
src/__tests__/completions.test.ts):Implementation Details
FALLBACK_COMPLETION_LANGUAGES; languages with native completion sources (JavaScript, Python, SQL, etc.) are unaffectedscopeCompletionSource(globalThis)to expose runtime globals!importantflags where necessary to override CodeMirror defaultshttps://claude.ai/code/session_01QAjpJTH4WCmyRXkMWLSosz