Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Add modifier completions for `@apply` and `classRegex` configs (#732)
Signature
-----BEGIN PGP SIGNATURE----- wsBcBAABCAAQBQJkDvr3CRBK7hj4Ov3rIwAAFawIACgzEuh7Z1MdpvjKqX3Ym/v1 SeF+VtdAh8sHGIBtJEXe7SYlQdxEzT1Gg8SuJm3nuGTrhfDLrcooIIiOntl+EDB5 vCCz1XG9GOyQN9j38guCHFvNbH/UyTqJFaHjb+JNKC1qvkMYee5ZThHiEj295X5c aBiUKkW6pAJ9smLQ/8fb7PbUlgqQxHpHMupHPfVfd+G93CUpgFV9RcYJyy7DRtwz rM6Qe5HWMY7Y6MYa0jtvhNHEfL63iiE4CxllJAZYKUbmoXTIDGR8QFRw0nOmtyvf ncC2RC1so6/tlQL4+sqLwLDQ5T26eTfXz1MtsVPgagbpOWcE8Avkcz4rhqZJhxU= =vPLt -----END PGP SIGNATURE-----
Brad Cornes <hello@bradley.dev>
2 years ago
1 changed files, 20 additions(+), 13 deletions(-)
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 0ca4912421f22290fee572e99e5184bc34314bb8..f5ec91955b0143315a0fb9634cc61d08805441f4 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -44,7 +44,6 @@   state: State,
   classList: string,
   classListRange: Range,
   filter?: (item: CompletionItem) => boolean,
-  document?: TextDocument,
   context?: CompletionContext
 ): CompletionList {
   let classNames = classList.split(/[\s+]/)
@@ -464,7 +463,6 @@           },
           end: position,
         },
         undefined,
-        document,
         context
       )
     }
@@ -476,7 +474,8 @@
 async function provideCustomClassNameCompletions(
   state: State,
   document: TextDocument,
-  position: Position
+  position: Position,
+  context?: CompletionContext
 ): Promise<CompletionList> {
   const settings = await state.editor.getConfiguration(document.uri)
   const regexes = settings.tailwindCSS.experimental.classRegex
@@ -527,13 +526,19 @@           } else {
             classList = containerMatch[1].substr(0, cursor - matchStart)
           }
 
-          return completionsFromClassList(state, classList, {
-            start: {
-              line: position.line,
-              character: position.character - classList.length,
+          return completionsFromClassList(
+            state,
+            classList,
+            {
+              start: {
+                line: position.line,
+                character: position.character - classList.length,
+              },
+              end: position,
             },
-            end: position,
-          })
+            undefined,
+            context
+          )
         }
       }
     } catch (_) {}
@@ -545,7 +550,8 @@
 function provideAtApplyCompletions(
   state: State,
   document: TextDocument,
-  position: Position
+  position: Position,
+  context?: CompletionContext
 ): CompletionList {
   let str = document.getText({
     start: { line: Math.max(position.line - 30, 0), character: 0 },
@@ -580,7 +586,8 @@       let variants = item.data?.variants ?? []
       let className = item.data?.className ?? item.label
       let validated = validateApply(state, [...variants, className])
       return validated !== null && validated.isApplyable === true
-    }
+    },
+    context
   )
 }
 
@@ -596,7 +603,7 @@   position: Position,
   context?: CompletionContext
 ): Promise<CompletionList> {
   if (isCssContext(state, document, position)) {
-    return provideAtApplyCompletions(state, document, position)
+    return provideAtApplyCompletions(state, document, position, context)
   }
 
   if (isHtmlContext(state, document, position) || isJsxContext(state, document, position)) {
@@ -1329,7 +1336,7 @@     provideVariantsDirectiveCompletions(state, document, position) ||
     provideTailwindDirectiveCompletions(state, document, position) ||
     provideLayerDirectiveCompletions(state, document, position) ||
     (await provideConfigDirectiveCompletions(state, document, position)) ||
-    (await provideCustomClassNameCompletions(state, document, position))
+    (await provideCustomClassNameCompletions(state, document, position, context))
 
   if (result) return result