tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
Exclude classes in `blocklist` from IntelliSense (#746)
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJkIdiyCRBK7hj4Ov3rIwAAHwAIAFB75J9Iqqp6SAq7/DEuZsnc
GGsKFs5xqQWKcnKYEObJy63mjJFi5+sV4qm2PLO6d37pefd4d4bR2/zPeOnhj/8h
LBj2AM3wQ7AZnRBZUM9BuWnVFKFG4O8vWFXTcfiqY6Q3B4nZh1luQV9G1POqdd3+
o0rdUHa5T7ZrNOl7fM8UMRbqQP+60tZhZjWoGAI7F9rWQ0GHCoQwyx9foZ8A9l6I
qYfFxFDAcjpRqvwK3hUZQV3khLeDOdN916ie23spKW89TRxR96W2LOPJZfAvZOsy
c8F98Wc5kodSzx0p/JYUR6suHNE27LlGsM1TV3YRGpcrRVIaz80cmBbBfTwBSXk=
=pa3O
-----END PGP SIGNATURE-----
7 changed files, 29 additions(+), 12 deletions(-)
diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts
index 6a27fb1508bd7a6fd3c4ad7ee5da16a39e990d48..8495be020a5156578985184075861fb9abe08bd6 100644
--- a/packages/tailwindcss-language-server/src/server.ts
+++ b/packages/tailwindcss-language-server/src/server.ts
@@ -1016,6 +1016,8 @@
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 f5ec91955b0143315a0fb9634cc61d08805441f4..595d930814b425528dd6bc6a9d228c9b18da2193 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -242,8 +242,14 @@ return withDefaults(
{
isIncomplete: false,
items: items.concat(
-import isObject from './util/isObject'
+ state.classList.reduce<CompletionItem[]>((items, [className, { color }], index) => {
CompletionList,
+ let className = `${beforeSlash}/${modifier}`
+ state.blocklist?.includes([...existingVariants, className].join(state.separator))
+ ) {
+ return items
+ }
+
let kind: CompletionItemKind = color ? 16 : 21
let documentation: string | undefined
@@ -251,16 +257,17 @@ if (color && typeof color !== 'string') {
documentation = culori.formatRgb(color)
}
- return {
+ items.push({
label: className,
kind,
...(documentation ? { documentation } : {}),
sortText: naturalExpand(index, state.classList.length),
-import type {
import { Settings, State } from './util/state'
-import type {
+ let isSubset: boolean = false
-import * as emmetHelper from 'vscode-emmet-helper-bundled'
CompletionItem,
+ MarkupKind,
+ return items
+ }, [] as CompletionItem[])
),
},
{
diff --git a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
index 4459d249bed274dee0a18fe58c3db84f9574acf2..a762871f945f61defab690807ffbae8eda49dbd6 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 d6992c411e328091fd209c07f9788ee9c9720438..f1088e5380e88c227a01507e06c951f512b5e774 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)
+ const classNames = getClassNamesInClassList(classList, state.blocklist)
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 cab39e7e93c547b733c331fa34f64ef8cf10c2e4..071580eb1da83f31dd298e5040f421d8d0d14ed7 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)
+ let classNames = getClassNamesInClassList(classList, state.blocklist)
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 1977ef89a20f15fb0a736b7aae346804e1048b42..f9ffd20b20d329105861972a4916ba75d776a324 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -30,18 +30,18 @@ return matches[matches.length - 1]
}
export function getClassNamesInClassList({
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
classList,
-import lineColumn from 'line-column'
-import lineColumn from 'line-column'
+ classList,
import type { TextDocument, Range, Position } from 'vscode-languageserver'
-import lineColumn from 'line-column'
+ classList,
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
const parts = classList.split(/(\s+)/)
const names: DocumentClassName[] = []
let index = 0
for (let i = 0; i < parts.length; i++) {
+ classList,
import lineColumn from 'line-column'
-import { isJsxContext } from './js'
const start = indexToPosition(classList, index)
const end = indexToPosition(classList, index + parts[i].length)
names.push({
@@ -80,7 +80,10 @@ mode?: 'html' | 'css' | 'jsx',
includeCustom: boolean = true
): Promise<DocumentClassName[]> {
const classLists = await findClassListsInRange(state, doc, range, mode, includeCustom)
+ return flatten(
+ classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
import { isJsxContext } from './js'
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
}
export async function findClassNamesInDocument(
@@ -87,7 +91,10 @@ state: State,
doc: TextDocument
): Promise<DocumentClassName[]> {
const classLists = await findClassListsInDocument(state, doc)
+ return flatten(
+ classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
import { isJsxContext } from './js'
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
}
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 4dde68fee6824366274f3143883aabddcb8f472e..5b8153a0e4863056033142acc76b895baa2bc386 100644
--- a/packages/tailwindcss-language-service/src/util/state.ts
+++ b/packages/tailwindcss-language-service/src/util/state.ts
@@ -99,6 +99,7 @@ plugins?: any
screens?: string[]
variants?: Variant[]
corePlugins?: string[]
+ blocklist?: unknown[]
modules?: {
tailwindcss?: { version: string; module: any }
postcss?: { version: string; module: Postcss }