diff --git a/packages/tailwindcss-language-server/src/projects.ts b/packages/tailwindcss-language-server/src/projects.ts index 3e53d7df..3a1df51d 100644 --- a/packages/tailwindcss-language-server/src/projects.ts +++ b/packages/tailwindcss-language-server/src/projects.ts @@ -45,6 +45,7 @@ import type { Settings, ClassNames, Variant, + ClassEntry, } from '@tailwindcss/language-service/src/util/state' import { provideDiagnostics } from './lsp/diagnosticsProvider' import { doCodeActions } from '@tailwindcss/language-service/src/codeActions/codeActionProvider' @@ -1014,7 +1015,7 @@ export async function createProjectService( }, }) - let classList = designSystem.getClassList().map((className) => { + let classList: ClassEntry[] = designSystem.getClassList().map((className) => { return [ className[0], { @@ -1025,7 +1026,8 @@ export async function createProjectService( }) state.designSystem = designSystem - state.classList = classList as any + state.classList = classList + state.variants = getVariants(state) console.log('---- RELOADED ----') }, diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index dd1966ce..d16ca186 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -89,6 +89,13 @@ export interface Variant { selectors: (params?: { value?: string; label?: string }) => string[] } +export interface ClassMetadata { + color: culori.Color | KeywordColor | null + modifiers?: string[] +} + +export type ClassEntry = [string, ClassMetadata] + export interface State { enabled: boolean isCssConfig?: boolean @@ -127,7 +134,7 @@ export interface State { editor?: EditorState jit?: boolean jitContext?: any - classList?: Array<[string, { color: culori.Color | KeywordColor | null; modifiers?: string[] }]> + classList?: ClassEntry[] classListContainsMetadata?: boolean pluginVersions?: string completionItemData?: Record diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md index 334caf09..f0c28083 100644 --- a/packages/vscode-tailwindcss/CHANGELOG.md +++ b/packages/vscode-tailwindcss/CHANGELOG.md @@ -2,7 +2,7 @@ ## Prerelease -- Nothing yet! +- Reload variants when editing the theme in v4 ([#1094](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1094)) ## 0.12.14