Skip to content

feat: advanced SQL syntax highlighting and expanded language support#6

Merged
muk2 merged 3 commits intomainfrom
feature/issue-4-advanced-sql
Feb 19, 2026
Merged

feat: advanced SQL syntax highlighting and expanded language support#6
muk2 merged 3 commits intomainfrom
feature/issue-4-advanced-sql

Conversation

@muk2
Copy link
Owner

@muk2 muk2 commented Feb 17, 2026

Summary

Addresses the core syntax and language support goals from #4 to make pgrsql a power-user SQL editor with first-class support for modern PostgreSQL features:

  • 200+ SQL keywords with comprehensive coverage for CTEs (WITH RECURSIVE), LATERAL joins, grouping sets (CUBE, ROLLUP, GROUPING SETS), transaction isolation levels, PL/pgSQL control flow (DECLARE, LOOP, RAISE, EXCEPTION), and DDL for functions, triggers, policies, extensions, and more
  • 250+ SQL built-in functions recognized and highlighted in a distinct color (blue), covering:
    • Aggregate functions (ARRAY_AGG, STRING_AGG, PERCENTILE_CONT, JSON_AGG, etc.)
    • Window functions (ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD, NTH_VALUE, CUME_DIST, etc.)
    • JSON/JSONB functions (JSONB_BUILD_OBJECT, JSONB_SET, JSONB_PATH_QUERY, ROW_TO_JSON, etc.)
    • Array functions (ARRAY_AGG, UNNEST, ARRAY_POSITION, CARDINALITY, etc.)
    • Date/time, string, numeric, full-text search, and system info functions
  • 90+ SQL types including range types (INT4RANGE, TSTZRANGE), multirange, OID types (REGCLASS, REGTYPE), full-text search (TSVECTOR, TSQUERY), and pseudo-types
  • Block comment support: /* */ comments are properly highlighted, including across multiple lines
  • PostgreSQL operator highlighting: :: (type cast), -> / ->> (JSON), #> / #>> (JSON path), @> / <@ (containment), ?| / ?& (JSONB existence), || (concatenation)
  • Escaped quote handling: '' inside string literals no longer breaks highlighting
  • Schema-qualified names: Dot operator (.) styled as muted for clean schema.table readability

Syntax Color Scheme

Element Color Example
Keywords Purple (bold) SELECT, WITH RECURSIVE, LATERAL
Functions Blue ROW_NUMBER(), JSONB_BUILD_OBJECT()
Types Yellow TIMESTAMPTZ, JSONB, INT4RANGE
Strings Green 'hello world'
Numbers Orange 42, 3.14
Comments Gray -- comment, /* block */
Operators Cyan ::, ->>, @>

Test plan

  • Verify CTE keywords highlight (WITH, RECURSIVE, AS)
  • Verify window function names highlight in blue (ROW_NUMBER, DENSE_RANK, LAG)
  • Verify JSONB operators highlight (->, ->>, @>, #>>)
  • Verify :: type cast operator highlights
  • Verify block comments /* ... */ highlight across multiple lines
  • Verify escaped quotes '' don't break string highlighting
  • Verify SQL types like TSVECTOR, INT4RANGE, REGCLASS highlight in yellow
  • Verify aggregate functions like ARRAY_AGG, STRING_AGG highlight in blue
  • Verify PL/pgSQL keywords like DECLARE, RAISE, LOOP highlight

🤖 Generated with Claude Code

muk2 and others added 3 commits February 17, 2026 21:32
- Greatly expanded SQL keyword coverage (200+): LATERAL joins, GROUPING
  SETS, CUBE, ROLLUP, MERGE, MATERIALIZED, transaction isolation levels,
  DDL for functions/triggers/policies/extensions, PL/pgSQL control flow
- Added SQL built-in function recognition (250+) with distinct color:
  aggregate functions, window functions, string/numeric/date functions,
  JSON/JSONB functions, array functions, full-text search, system info
- Expanded SQL type coverage (90+): range types, multirange types, OID
  types (regclass, regtype, etc.), full-text search types, pseudo-types
- Block comment (/* */) syntax highlighting with multi-line support
- PostgreSQL-specific operator highlighting: ::, ->, ->>, #>, #>>,
  @>, <@, ?|, ?&, ||, and comparison operators
- Escaped single-quote ('') handling inside string literals
- Dot operator styled as muted for schema.table notation clarity
- Functions highlighted in distinct color (blue) vs keywords (purple)

Closes #4

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep is_sql_function from feature branch and tests from main.
Fix duplicate entries in SQL_KEYWORDS (ONLY) and SQL_FUNCTIONS
(GREATEST, LEAST, GENERATE_SERIES). Update tests for ROW_NUMBER
being a function instead of a keyword, add function list tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrate the gutter marker for active query blocks from main while
preserving the advanced SQL syntax highlighting from the feature branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@muk2 muk2 merged commit 3f52ea0 into main Feb 19, 2026
9 checks passed
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

Successfully merging this pull request may close these issues.

1 participant