Skip to content

Include the theme prefix in variable completions inside var(…) - #1630

Open
wook10 wants to merge 2 commits into
tailwindlabs:mainfrom
wook10:fix/var-completions-prefix
Open

wook10 wants to merge 2 commits into
tailwindlabs:mainfrom
wook10:fix/var-completions-prefix

Conversation

@wook10

@wook10 wook10 commented Oct 30, 2026 •

Copy link
Copy Markdown

Fixes #1595

Summary

With a prefix (e.g. @import "tailwindcss" prefix(tw)), the theme variables Tailwind emits are prefixed: --tw-color-red-500, --tw-font-sans, etc. Completions inside var(…) still suggested the unprefixed names, which don't exist in the output CSS.

var(…), theme(…) and --theme(…) all get their items from themeKeyCompletions(), which uses resolveKnownThemeKeys(). That function strips the prefix, which is right for theme(…) / --theme(…) but not for var(…).

This passes the helper name to themeKeyCompletions() and, for var(…) only, adds the prefix back to the label. Values and color previews are still resolved from the unprefixed key. Without a prefix the labels are unchanged.

Test plan

Added two tests to tests/completions/completions.test.js:

  • var(…) with prefix(tw) suggests --tw-font-sans and --tw-color-custom (still shown as a color), and nothing unprefixed. Fails without this change (--font-sans is suggested instead).
  • --theme(…) with prefix(tw) still suggests unprefixed keys. Passes before and after.
cd packages/tailwindcss-language-server
pnpm exec vitest run tests/completions/completions.test.js -t "Theme key"

The whole tests/completions/completions.test.js file passes (48 tests). I also ran vitest run in packages/tailwindcss-language-service (734 tests pass) and tsc --noEmit there (no errors).

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Reviews (1) · Last reviewed commit: "Update changelog" · Reviewed by Greptile

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.

[Bug]: VS Code Autocompletion for Tailwind's Generated CSS Variables Doesn't Account for Prefixes

1 participant