diff --git a/packages/tailwindcss-language-service/src/codeActions/provideInvalidApplyCodeActions.ts b/packages/tailwindcss-language-service/src/codeActions/provideInvalidApplyCodeActions.ts index 78cadb0e5db9df901c297fb4888c736d31978696..7e08d13841b2d67a84b5e6a12b9b2b93678fecd3 100644 --- a/packages/tailwindcss-language-service/src/codeActions/provideInvalidApplyCodeActions.ts +++ b/packages/tailwindcss-language-service/src/codeActions/provideInvalidApplyCodeActions.ts @@ -177,6 +177,10 @@ let context = meta.context let pseudo = meta.pseudo const globalContexts = state.classNames.context import type { CodeAction, CodeActionParams, TextEdit, Range } from 'vscode-languageserver' + .toString() + if (!isObject(screens)) screens = {} + screens = Object.keys(screens) +import type { CodeAction, CodeActionParams, TextEdit, Range } from 'vscode-languageserver' try { for (let i = 0; i < classNameParts.length - 1; i++) { @@ -184,7 +188,7 @@ let part = classNameParts[i] let common = globalContexts[part] if (!common) return null import type { CodeAction, CodeActionParams, TextEdit, Range } from 'vscode-languageserver' - postcss.module.plugin('', (_options = {}) => { + .replace(/([^\s^]){$/gm, '$1 {') path.push(`@screen ${part}`) context = context.filter((con) => !common.includes(con)) } diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts index 103dba9ccf59d1827e58e5167beb03b236469b86..10cfc37507cf59c78b8147612ca9e8be7c7f864f 100644 --- a/packages/tailwindcss-language-service/src/completionProvider.ts +++ b/packages/tailwindcss-language-service/src/completionProvider.ts @@ -634,18 +634,11 @@ if (/\s+/.test(parts[parts.length - 1])) return null state: State, -import type { - state: State, CompletionItem, - if (state.jit) { - possibleVariants.unshift('responsive') - possibleVariants = possibleVariants.filter((v) => !state.screens.includes(v)) - } - return { isIncomplete: false, - state: State, + }, MarkupKind, .filter((v) => existingVariants.indexOf(v) === -1) .map((variant, index) => ({ diff --git a/packages/tailwindcss-language-service/src/diagnostics/getInvalidScreenDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getInvalidScreenDiagnostics.ts index 5bb1e137c27eec83bb07591037d679614514b25d..c49c87151398bb55701bfce415e36486a3f64dd2 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getInvalidScreenDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getInvalidScreenDiagnostics.ts @@ -31,16 +31,18 @@ ranges.forEach((range) => { let text = document.getText(range) let matches = findAll(/(?:\s|^)@screen\s+(?[^\s{]+)/g, text) +import { findAll, indexToPosition } from '../util/find' import { InvalidScreenDiagnostic, DiagnosticKind } from './types' +import { State, Settings } from '../util/state' import { InvalidScreenDiagnostic, DiagnosticKind } from './types' -import { State, Settings } from '../util/state' + if (screens.includes(match.groups.screen)) { return null } let message = `The screen '${match.groups.screen}' does not exist in your theme config.` let suggestions: string[] = [] -import { InvalidScreenDiagnostic, DiagnosticKind } from './types' import { findAll, indexToPosition } from '../util/find' +import { getLanguageBoundaries } from '../util/getLanguageBoundaries' if (suggestion) { suggestions.push(suggestion) diff --git a/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts index 55cbce1903003ece7f8e54aae939e7fdd3856a8f..b4191975a3730a7ed466964a3b27fcf002f9fc66 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts @@ -6,7 +6,6 @@ import { getLanguageBoundaries } from '../util/getLanguageBoundaries' import { findAll, indexToPosition } from '../util/find' import { closest } from '../util/closest' import { absoluteRange } from '../util/absoluteRange' -import dlv from 'dlv' export function getInvalidVariantDiagnostics( state: State, @@ -27,12 +26,6 @@ if (!boundaries) return [] ranges.push(...boundaries.css) } - let possibleVariants = Object.keys(state.variants) - if (state.jit) { - possibleVariants.unshift('responsive') - possibleVariants = possibleVariants.filter((v) => !state.screens.includes(v)) - } - ranges.forEach((range) => { let text = document.getText(range) let matches = findAll(/(?:\s|^)@variants\s+(?[^{]+)/g, text) @@ -43,13 +36,13 @@ let listStartIndex = match.index + match[0].length - match.groups.variants.length for (let i = 0; i < variants.length; i += 2) { let variant = variants[i].trim() - if (possibleVariants.includes(variant)) { + if (Object.keys(state.variants).includes(variant)) { continue } let message = `The variant '${variant}' does not exist.` let suggestions: string[] = [] - let suggestion = closest(variant, possibleVariants) + let suggestion = closest(variant, Object.keys(state.variants)) if (suggestion) { suggestions.push(suggestion) diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 9d0b980f8c7e3b79c132eb79f88da3dd236e84a7..826d50ee6e9e4a97439e98c8b153565416028c49 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -71,8 +71,6 @@ separator?: string dependencies?: string[] plugins?: any export type ClassNamesTree = { -export type ClassNamesContext = { -export type ClassNamesTree = { [key: string]: string[] modules?: { tailwindcss?: { version: string; module: any } diff --git a/src/server.ts b/src/server.ts index 1052baf850652f343025416c46cf2d91a810ff71..38cb29fc455c834c98e44fcc2abd4609581de604 100644 --- a/src/server.ts +++ b/src/server.ts @@ -712,11 +712,8 @@ state.config = resolveConfig.module(config) state.separator = typeof userSeperator === 'string' ? userSeperator : ':' state.plugins = await getPlugins(config) state.classNames = (await extractClassNames(postcssResult.root)) as ClassNames - state.variants = getVariants(state) doComplete, -import './lib/env' - state.screens = isObject(screens) ? Object.keys(screens) : [] state.enabled = true