Add SQL syntax highlighting to interactive REPL#2
Open
tobias-fire wants to merge 1 commit intofeature/client-side-renderingfrom
Open
Add SQL syntax highlighting to interactive REPL#2tobias-fire wants to merge 1 commit intofeature/client-side-renderingfrom
tobias-fire wants to merge 1 commit intofeature/client-side-renderingfrom
Conversation
Implements regex-based syntax highlighting for SQL queries in the
interactive REPL mode with industry-standard color scheme.
Features:
- Keywords (SELECT, FROM, WHERE): Bright Blue
- Functions (COUNT, AVG): Bright Cyan
- Strings ('text'): Bright Yellow
- Numbers (42, 3.14): Bright Magenta
- Comments (-- text): Bright Black (gray)
- Operators: Default (subtle)
Configuration:
- Auto-enabled in interactive TTY mode
- Disabled via --no-color flag
- Respects NO_COLOR environment variable
- Auto-disabled for piped/redirected output
Implementation:
- Regex-based highlighting (no new dependencies)
- 13 comprehensive unit tests
- Graceful error handling
- Colorblind-accessible color scheme based on DuckDB, pgcli, and
accessibility research
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Summary
Adds real-time SQL syntax highlighting to the interactive REPL mode with an industry-standard, research-based color scheme.
Features
Syntax Highlighting:
Configuration:
--no-colorflagNO_COLORenvironment variableImplementation
regexcrate)Technical Details
New Files:
src/highlight.rs(321 lines) - Core highlighting logic with unit testssrc/repl_helper.rs(56 lines) - Rustyline integrationModified Files:
src/args.rs- Addedno_colorflag andshould_use_colors()methodsrc/main.rs- Integrated highlighter into REPL editor setupCargo.toml/Cargo.lock- No new dependenciesDesign Decision - Regex vs Tree-sitter:
Initially planned to use tree-sitter, but switched to regex because:
Color Scheme Research
The color scheme was improved based on research of:
Key improvements:
Testing
✅ All 95 unit tests pass
✅ All 23 integration tests pass
✅ 13 new highlighting tests added
Example Usage
Try these queries:
Backward Compatibility
✅ All existing functionality preserved
✅ Colors enabled by default in interactive mode
✅ Automatically disabled for piped output
✅ No breaking changes to CLI interface
🤖 Generated with Claude Code