Skip to content

Highlight CTE aliases as variable instead of type#42

Open
owensilk wants to merge 1 commit into
zed-extensions:mainfrom
owensilk:fix/cte-alias-highlight
Open

Highlight CTE aliases as variable instead of type#42
owensilk wants to merge 1 commit into
zed-extensions:mainfrom
owensilk:fix/cte-alias-highlight

Conversation

@owensilk
Copy link
Copy Markdown

Problem

CTE (Common Table Expression) names in SQL are currently highlighted as @type (line 4 of highlights.scm):

(cte (identifier) @type)

This causes CTE aliases (e.g. my_cte in WITH my_cte AS (...)) to be coloured the same as actual type references like table names and data types. CTE names are aliases, not types — they should be visually distinct.

Fix

Change the capture from @type to @variable, which is consistent with how term alias is already handled on line 27:

(term
  alias: (identifier) @variable)

Both CTE names and column/expression aliases serve the same semantic role (user-defined aliases), so they should share the same highlight group.

Before / After

Before After
CTE aliases highlighted as @type (same color as table references) CTE aliases highlighted as @variable (same as other aliases)

CTE (Common Table Expression) names are aliases, not types. They should
be highlighted as @variable (consistent with how term aliases are already
handled) rather than @type, which is semantically reserved for table/view
references and data types.
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Feb 10, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @owensilk on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@owensilk
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Feb 10, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @owensilk on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Feb 10, 2026

The cla-bot has been summoned, and re-checked this pull request!

@MrSubidubi
Copy link
Copy Markdown
Contributor

Hey, thanks for this! Did you sign the CLA yet? Our API indicates you did not, although I can see your attempts above. Happy to help if needed. Thanks!

@MrSubidubi MrSubidubi changed the title fix: highlight CTE aliases as @variable instead of @type Highlight CTE aliases as variable instead of type Feb 17, 2026
@owensilk
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Feb 24, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @owensilk on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Feb 24, 2026

The cla-bot has been summoned, and re-checked this pull request!

@owensilk
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Feb 24, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Feb 24, 2026

The cla-bot has been summoned, and re-checked this pull request!

@MrSubidubi
Copy link
Copy Markdown
Contributor

Definitely looks like a reasonable improvement and fix, do you perhaps have a before/after as screenshots to compare this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants