Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
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-----
Brad Cornes <hello@bradley.dev>
2 years ago
7 changed files, 29 additions(+), 15 deletions(-)
M packages/tailwindcss-language-server/src/server.ts -> packages/tailwindcss-language-server/src/server.ts
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)
M packages/tailwindcss-language-service/src/completionProvider.ts -> packages/tailwindcss-language-service/src/completionProvider.ts
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,7 +242,13 @@       return withDefaults(
         {
           isIncomplete: false,
           items: items.concat(
-            state.classList.map(([className, { color }], index) => {
+            state.classList.reduce<CompletionItem[]>((items, [className, { color }], index) => {
+              if (
+                state.blocklist?.includes([...existingVariants, className].join(state.separator))
+              ) {
+                return items
+              }
+
               let kind: CompletionItemKind = color ? 16 : 21
               let documentation: string | undefined
 
@@ -250,13 +256,15 @@               if (color && typeof color !== 'string') {
                 documentation = culori.formatRgb(color)
               }
 
-              return {
+              items.push({
                 label: className,
                 kind,
                 ...(documentation ? { documentation } : {}),
                 sortText: naturalExpand(index, state.classList.length),
-              } as CompletionItem
-            })
+              })
+
+              return items
+            }, [] as CompletionItem[])
           ),
         },
         {
M packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts -> packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
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,7 +20,7 @@   let diagnostics: CssConflictDiagnostic[] = []
   const classLists = await findClassListsInDocument(state, document)
 
   classLists.forEach((classList) => {
-    const classNames = getClassNamesInClassList(classList)
+    const classNames = getClassNamesInClassList(classList, state.blocklist)
 
     classNames.forEach((className, index) => {
       if (state.jit) {
M packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts -> packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts
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) {
M packages/tailwindcss-language-service/src/documentColorProvider.ts -> packages/tailwindcss-language-service/src/documentColorProvider.ts
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) {
M packages/tailwindcss-language-service/src/util/find.ts -> packages/tailwindcss-language-service/src/util/find.ts
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
@@ -29,16 +29,15 @@   }
   return matches[matches.length - 1]
 }
 
-export function getClassNamesInClassList({
-  classList,
-  range,
-  important,
-}: DocumentClassList): DocumentClassName[] {
+export function getClassNamesInClassList(
+  { classList, range, important }: DocumentClassList,
+  blocklist: State['blocklist']
+): DocumentClassName[] {
   const parts = classList.split(/(\s+)/)
   const names: DocumentClassName[] = []
   let index = 0
   for (let i = 0; i < parts.length; i++) {
-    if (i % 2 === 0) {
+    if (i % 2 === 0 && !blocklist.includes(parts[i])) {
       const start = indexToPosition(classList, index)
       const end = indexToPosition(classList, index + parts[i].length)
       names.push({
@@ -77,7 +76,9 @@   mode?: 'html' | 'css' | 'jsx',
   includeCustom: boolean = true
 ): Promise<DocumentClassName[]> {
   const classLists = await findClassListsInRange(state, doc, range, mode, includeCustom)
-  return flatten(classLists.map(getClassNamesInClassList))
+  return flatten(
+    classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
+  )
 }
 
 export async function findClassNamesInDocument(
@@ -85,7 +86,9 @@   state: State,
   doc: TextDocument
 ): Promise<DocumentClassName[]> {
   const classLists = await findClassListsInDocument(state, doc)
-  return flatten(classLists.map(getClassNamesInClassList))
+  return flatten(
+    classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
+  )
 }
 
 export function findClassListsInCssRange(doc: TextDocument, range?: Range): DocumentClassList[] {
M packages/tailwindcss-language-service/src/util/state.ts -> packages/tailwindcss-language-service/src/util/state.ts
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 }