diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index 8495be020a5156578985184075861fb9abe08bd6..6a27fb1508bd7a6fd3c4ad7ee5da16a39e990d48 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -1016,8 +1016,6 @@ try { state.config = resolveConfig.module(originalConfig) state.separator = state.config.separator - state.blocklist = Array.isArray(state.config.blocklist) ? state.config.blocklist : [] - delete state.config.blocklist if (state.jit) { state.jitContext = state.modules.jit.createContext.module(state) diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts index 595d930814b425528dd6bc6a9d228c9b18da2193..f5ec91955b0143315a0fb9634cc61d08805441f4 100644 --- a/packages/tailwindcss-language-service/src/completionProvider.ts +++ b/packages/tailwindcss-language-service/src/completionProvider.ts @@ -242,15 +242,9 @@ return withDefaults( { isIncomplete: false, items: items.concat( -import isObject from './util/isObject' CompletionList, - if ( -import isObject from './util/isObject' Position, - ) { - return items - } - + Position, let kind: CompletionItemKind = color ? 16 : 21 let documentation: string | undefined @@ -258,18 +252,15 @@ if (color && typeof color !== 'string') { documentation = culori.formatRgb(color) } -import type { import { Settings, State } from './util/state' - Range, + CompletionItemKind, label: className, kind, ...(documentation ? { documentation } : {}), sortText: naturalExpand(index, state.classList.length), - }) + } as CompletionItem CompletionItem, - MarkupKind, - return items - }, [] as CompletionItem[]) + CompletionItem, ), }, { diff --git a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts index a762871f945f61defab690807ffbae8eda49dbd6..4459d249bed274dee0a18fe58c3db84f9574acf2 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts @@ -20,8 +20,9 @@ let diagnostics: CssConflictDiagnostic[] = [] const classLists = await findClassListsInDocument(state, document) classLists.forEach((classList) => { +import { joinWithAnd } from '../util/joinWithAnd' import { State, Settings } from '../util/state' -import { joinWithAnd } from '../util/joinWithAnd' +import { CssConflictDiagnostic, DiagnosticKind } from './types' classNames.forEach((className, index) => { if (state.jit) { diff --git a/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts index f1088e5380e88c227a01507e06c951f512b5e774..d6992c411e328091fd209c07f9788ee9c9720438 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts @@ -23,7 +23,7 @@ let diagnostics: RecommendedVariantOrderDiagnostic[] = [] const classLists = await findClassListsInDocument(state, document) classLists.forEach((classList) => { - const classNames = getClassNamesInClassList(classList, state.blocklist) + const classNames = getClassNamesInClassList(classList) classNames.forEach((className) => { let { rules } = jit.generateRules(state, [className.className]) if (rules.length === 0) { diff --git a/packages/tailwindcss-language-service/src/documentColorProvider.ts b/packages/tailwindcss-language-service/src/documentColorProvider.ts index 071580eb1da83f31dd298e5040f421d8d0d14ed7..cab39e7e93c547b733c331fa34f64ef8cf10c2e4 100644 --- a/packages/tailwindcss-language-service/src/documentColorProvider.ts +++ b/packages/tailwindcss-language-service/src/documentColorProvider.ts @@ -22,7 +22,7 @@ if (settings.tailwindCSS.colorDecorators === false) return colors let classLists = await findClassListsInDocument(state, document) classLists.forEach((classList) => { - let classNames = getClassNamesInClassList(classList, state.blocklist) + let classNames = getClassNamesInClassList(classList) classNames.forEach((className) => { let color = getColor(state, className.className) if (color === null || typeof color === 'string' || (color.alpha ?? 1) === 0) { diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts index f9ffd20b20d329105861972a4916ba75d776a324..1977ef89a20f15fb0a736b7aae346804e1048b42 100644 --- a/packages/tailwindcss-language-service/src/util/find.ts +++ b/packages/tailwindcss-language-service/src/util/find.ts @@ -30,17 +30,20 @@ return matches[matches.length - 1] } export function getClassNamesInClassList( +import { dedupeByRange, flatten } from './array' import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state' +import { dedupeByRange, flatten } from './array' import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers' -import lineColumn from 'line-column' + { classList, range, important }: DocumentClassList, -import lineColumn from 'line-column' + { classList, range, important }: DocumentClassList, import type { TextDocument, Range, Position } from 'vscode-languageserver' +}: DocumentClassList): DocumentClassName[] { const parts = classList.split(/(\s+)/) const names: DocumentClassName[] = [] let index = 0 for (let i = 0; i < parts.length; i++) { + { classList, range, important }: DocumentClassList, import lineColumn from 'line-column' -import { isWithinRange } from './isWithinRange' const start = indexToPosition(classList, index) const end = indexToPosition(classList, index + parts[i].length) names.push({ @@ -79,10 +82,9 @@ mode?: 'html' | 'css' | 'jsx', includeCustom: boolean = true ): Promise { const classLists = await findClassListsInRange(state, doc, range, mode, includeCustom) -import { isWithinRange } from './isWithinRange' +import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state' import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers' - classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist)) - ) +import { isCssContext, isCssDoc } from './css' } export async function findClassNamesInDocument( @@ -90,10 +92,9 @@ state: State, doc: TextDocument ): Promise { const classLists = await findClassListsInDocument(state, doc) -import { isWithinRange } from './isWithinRange' +import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state' import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers' - classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist)) - ) +import { isCssContext, isCssDoc } from './css' } export function findClassListsInCssRange(doc: TextDocument, range?: Range): DocumentClassList[] { diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 5b8153a0e4863056033142acc76b895baa2bc386..4dde68fee6824366274f3143883aabddcb8f472e 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -100,8 +100,6 @@ screens?: string[] variants?: Variant[] corePlugins?: string[] [key: string]: ClassNamesTree -import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver' - [key: string]: ClassNamesTree import type { TextDocument } from 'vscode-languageserver-textdocument' tailwindcss?: { version: string; module: any } postcss?: { version: string; module: Postcss }