Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Update variant API for compatibility with `v3-alpha.2`
Brad Cornes <bradlc41@gmail.com>
3 years ago
1 changed files, 26 additions(+), 4 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 9fbdd0b2090c24e3971d230f6fb902d436b91442..426a1c697b31df5f5d3d29861f4e88460be2300c 100644
--- a/packages/tailwindcss-language-server/src/server.ts
+++ b/packages/tailwindcss-language-server/src/server.ts
@@ -39,7 +39,7 @@ import chokidar, { FSWatcher } from 'chokidar'
 import findUp from 'find-up'
 import minimatch from 'minimatch'
 import resolveFrom, { setPnpApi } from './util/resolveFrom'
-import { /*postcssFallback,*/ Result } from 'postcss'
+import { /*postcssFallback,*/ AtRule, Container, Node, Result } from 'postcss'
 // import tailwindcssFallback from 'tailwindcss'
 // import resolveConfigFallback from 'tailwindcss/resolveConfig'
 import Module from 'module'
@@ -1096,6 +1096,10 @@     })
   } catch (_) {}
 }
 
+function isAtRule(node: Node): node is AtRule {
+  return node.type === 'atrule'
+}
+
 function getVariants(state: State): Record<string, string> {
   if (state.jit) {
     function escape(className: string): string {
@@ -1153,19 +1157,37 @@
         let definitions = []
 
         for (let fn of fns) {
+          let definition: string
           let container = root.clone()
-          fn({
+          let returnValue = fn({
             container,
             separator: state.separator,
             modifySelectors,
+            format: (def: string) => {
+              definition = def.replace(/:merge\(([^)]+)\)/g, '$1')
+            },
+            wrap: (rule: Container) => {
+              if (isAtRule(rule)) {
+                definition = `@${rule.name} ${rule.params}`
+              }
+            },
           })
 
+          if (!definition) {
+            definition = returnValue
+          }
+
+          if (definition) {
+            definitions.push(definition)
+            continue
+          }
+
           container.walkDecls((decl) => {
             decl.remove()
           })
 
-  DocumentColorParams,
+  ColorPresentation,
-  DocumentColorParams,
+  CompletionItem,
             .toString()
             .replace(`.${escape(`${variantName}:${placeholder}`)}`, '&')
             .replace(/(?<!\\)[{}]/g, '')