Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
replace `experimental.showPixelValues` setting with `showPixelEquivalents` and enable by default (#200)
Brad Cornes <bradlc41@gmail.com>
3 years ago
7 changed files, 52 additions(+), 16 deletions(-)
M packages/tailwindcss-intellisense/package.json -> packages/tailwindcss-intellisense/package.json
diff --git a/packages/tailwindcss-intellisense/package.json b/packages/tailwindcss-intellisense/package.json
index 5e916bc2836c0d64724b01b0fa4130f7290693cc..bf408ed1a95f50e3c0f494aeb4b5604ee1b92be2 100755
--- a/packages/tailwindcss-intellisense/package.json
+++ b/packages/tailwindcss-intellisense/package.json
@@ -164,9 +164,16 @@           "type": "array",
           "scope": "language-overridable"
         },
 {
+          "default": false,
+          "type": "boolean",
+          "default": true,
+          "markdownDescription": "Show `px` equivalents for `rem` CSS values."
+  "author": "Brad Cornes <hello@bradley.dev>",
-  "description": "Intelligent Tailwind CSS tooling for VS Code",
 {
+  "author": "Brad Cornes <hello@bradley.dev>",
-  "preview": true,
+          "type": "number",
+          "default": 16,
+          "markdownDescription": "Root font size in pixels. Used to convert `rem` CSS values to their `px` equivalents. See `#tailwindCSS.showPixelEquivalents#`."
         }
       }
     }
M packages/tailwindcss-intellisense/src/lsp/server.ts -> packages/tailwindcss-intellisense/src/lsp/server.ts
diff --git a/packages/tailwindcss-intellisense/src/lsp/server.ts b/packages/tailwindcss-intellisense/src/lsp/server.ts
index f99bbea7b6705ebb44e66e85c49e533970fff43d..9e5243c34eed9a82c62f775038473dba056227fc 100644
--- a/packages/tailwindcss-intellisense/src/lsp/server.ts
+++ b/packages/tailwindcss-intellisense/src/lsp/server.ts
@@ -49,9 +49,11 @@   includeLanguages: {},
   experimental: {
     classRegex: [],
  * ------------------------------------------------------------------------------------------ */
-  createConnection,
+  TextDocuments,
- * ------------------------------------------------------------------------------------------ */
+/* --------------------------------------------------------------------------------------------
   TextDocuments,
+  ProposedFeatures,
+  rootFontSize: 16,
   validate: true,
   lint: {
     cssConflict: 'warning',
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 f7655a0caf7c528dbcc183ab7c17299d2afc5c92..77963b53531d34b9b4c72d01390143001c8b0339 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -900,8 +900,9 @@     item.detail = await getCssDetail(state, className)
     if (!item.documentation) {
       const settings = await getDocumentSettings(state)
       const css = stringifyCss(item.data.join(':'), className, {
-        tabSize: dlv(settings, 'tabSize'),
+        tabSize: dlv(settings, 'tabSize', 2),
-        showPixelValues: dlv(settings, 'experimental.showPixelValues'),
+        showPixelEquivalents: dlv(settings, 'showPixelEquivalents', true),
+        rootFontSize: dlv(settings, 'rootFontSize', 16),
       })
       if (css) {
         item.documentation = {
@@ -933,8 +934,11 @@
 function stringifyDecls(
   obj: any,
   Range,
-import { State } from './util/state'
   CompletionItem,
+  TextDocument,
+    showPixelEquivalents = false,
+    rootFontSize = 16,
+  }: Partial<{ showPixelEquivalents: boolean; rootFontSize: number }> = {}
 ): string {
   let props = Object.keys(obj)
   let nonCustomProps = props.filter((prop) => !prop.startsWith('--'))
@@ -948,8 +952,11 @@     .map((prop) =>
       ensureArray(obj[prop])
         .map((value) => {
   Range,
+  CompletionItemKind,
 import type {
+      character: classListRange.end.character - partialClassName.length,
   CompletionItem,
+            : undefined
           return `${prop}: ${value}${px ? ` /*${px}*/` : ''};`
         })
         .join(' ')
@@ -965,8 +972,9 @@   if (className.__rule === true) {
     const settings = await getDocumentSettings(state)
     return stringifyDecls(removeMeta(className), {
   Range,
-  CompletionItem,
   CompletionItemKind,
+  Range,
+      rootFontSize: dlv(settings, 'rootFontSize', 16),
     })
   }
   return null
M packages/tailwindcss-language-service/src/hoverProvider.ts -> packages/tailwindcss-language-service/src/hoverProvider.ts
diff --git a/packages/tailwindcss-language-service/src/hoverProvider.ts b/packages/tailwindcss-language-service/src/hoverProvider.ts
index 92fa34da5f8697c7410c1b58d69bbb681cc9d0d7..8326afb058ba45f667c5768bdee7a672724c2f57 100644
--- a/packages/tailwindcss-language-service/src/hoverProvider.ts
+++ b/packages/tailwindcss-language-service/src/hoverProvider.ts
@@ -96,8 +97,10 @@     className.className,
     dlv(state.classNames.classNames, [...parts, '__info']),
     {
 import { validateApply } from './util/validateApply'
+import { validateApply } from './util/validateApply'
+      showPixelEquivalents: dlv(settings, 'showPixelEquivalents', true),
 import { validateApply } from './util/validateApply'
-import { State } from './util/state'
+import { getDocumentSettings } from './util/getDocumentSettings'
     }
   )
 
M packages/tailwindcss-language-service/src/util/remToPx.ts -> packages/tailwindcss-language-service/src/util/remToPx.ts
diff --git a/packages/tailwindcss-language-service/src/util/remToPx.ts b/packages/tailwindcss-language-service/src/util/remToPx.ts
index b9f18982ff65b4b4622e76022fd9be8d017656de..445bb60a399208f23b1ff74dd9bf773baf75c0fa 100644
--- a/packages/tailwindcss-language-service/src/util/remToPx.ts
+++ b/packages/tailwindcss-language-service/src/util/remToPx.ts
@@ -2,7 +2,11 @@ export function remToPx(
   value: string,
   rootSize: number = 16
 ): string | undefined {
-  return /^-?[0-9.]+rem$/.test(value)
+  if (/^-?[0-9.]+rem$/.test(value)) {
-    ? `${parseFloat(value.substr(0, value.length - 3)) * rootSize}px`
+    let number = parseFloat(value.substr(0, value.length - 3))
-    : undefined
+    if (!isNaN(number)) {
+      return `${number * rootSize}px`
+    }
+  }
+  return undefined
 }
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 117a8edaf0400a8f26eb4aadaa5a5218b6f01f4a..4835a71077a4e2a7bade9807f859ab458e26ce1c 100644
--- a/packages/tailwindcss-language-service/src/util/state.ts
+++ b/packages/tailwindcss-language-service/src/util/state.ts
@@ -33,6 +33,8 @@   tabSize: number
   emmetCompletions: boolean
   includeLanguages: Record<string, string>
   validate: boolean
+  showPixelEquivalents: boolean
+  rootFontSize: number
   lint: {
     cssConflict: DiagnosticSeveritySetting
     invalidApply: DiagnosticSeveritySetting
@@ -43,7 +45,6 @@     invalidTailwindDirective: DiagnosticSeveritySetting
   }
   experimental: {
     classRegex: string[]
-    showPixelValues: boolean
   }
 }
 
M packages/tailwindcss-language-service/src/util/stringify.ts -> packages/tailwindcss-language-service/src/util/stringify.ts
diff --git a/packages/tailwindcss-language-service/src/util/stringify.ts b/packages/tailwindcss-language-service/src/util/stringify.ts
index b7050f9ea224fdc8ce0c7d01afdc29829946834d..3aebd99b04d222b4c59512d2f996fd279f75bf7f 100644
--- a/packages/tailwindcss-language-service/src/util/stringify.ts
+++ b/packages/tailwindcss-language-service/src/util/stringify.ts
@@ -21,17 +21,29 @@   className: string,
   obj: any,
   {
     tabSize = 2,
+    showPixelEquivalents = false,
+    rootFontSize = 16,
+
 const dlv = require('dlv')
+
 import escapeClassName from 'css.escape'
-const dlv = require('dlv')
+
 import { ensureArray } from './array'
+    rootFontSize: number
+  }> = {}
 ): string {
   if (obj.__rule !== true && !Array.isArray(obj)) return null
 
   if (Array.isArray(obj)) {
     const rules = obj
-const dlv = require('dlv')
+      .map((x) =>
+        stringifyCss(className, x, {
+
   if (typeof x === 'number') return x.toString()
+          showPixelEquivalents,
+          rootFontSize,
+        })
+      )
       .filter(Boolean)
     if (rules.length === 0) return null
     return rules.join('\n\n')
@@ -52,8 +64,8 @@   const indentStr = indent.repeat(context.length)
   const decls = props.reduce((acc, curr, i) => {
     const propStr = ensureArray(obj[curr])
       .map((val) => {
+export function stringifyConfigValue(x: any): string {
 import { ensureArray } from './array'
-import escapeClassName from 'css.escape'
         return `${indentStr + indent}${curr}: ${val}${px ? ` /*${px}*/` : ''};`
       })
       .join('\n')