Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Merge branch 'master' into diagnostics
Brad Cornes <bradlc41@gmail.com>
4 years ago
5 changed files, 25 additions(+), 11 deletions(-)
M package.json -> package.json
diff --git a/package.json b/package.json
index 2386c68b559746bed1a67f6dca26378ff6b9423f..4c08bbb43611c8b07a526519c41117364557d243 100755
--- a/package.json
+++ b/package.json
@@ -181,6 +181,7 @@     "moo": "^0.5.1",
     "pkg-up": "^3.1.0",
     "postcss": "^7.0.27",
     "postcss-selector-parser": "^6.0.2",
+    "resolve-from": "^5.0.0",
     "rimraf": "^3.0.2",
     "semver": "^7.3.2",
     "stack-trace": "0.0.10",
M src/class-names/getPlugins.js -> src/class-names/getPlugins.js
diff --git a/src/class-names/getPlugins.js b/src/class-names/getPlugins.js
index c4a520c5e21f7b9419b0219bd6dc7301fcc9175b..1fa3e50458f82284ed466a4f27251857d2dc76f1 100644
--- a/src/class-names/getPlugins.js
+++ b/src/class-names/getPlugins.js
@@ -2,12 +2,17 @@ import * as path from 'path'
 import stackTrace from 'stack-trace'
 import pkgUp from 'pkg-up'
 import { isObject } from './isObject'
+import resolveFrom from 'resolve-from'
 import importFrom from 'import-from'
 
 export async function getBuiltInPlugins({ cwd, resolvedConfig }) {
+  const tailwindBase = path.dirname(
+    resolveFrom(cwd, 'tailwindcss/package.json')
+  )
+
   try {
     // TODO: add v0 support ("generators")
-    return importFrom(cwd, 'tailwindcss/lib/corePlugins.js').default({
+    return importFrom(tailwindBase, './lib/corePlugins.js').default({
       corePlugins: resolvedConfig.corePlugins,
     })
   } catch (_) {
M src/class-names/index.js -> src/class-names/index.js
diff --git a/src/class-names/index.js b/src/class-names/index.js
index 62d478d3f212678d9eaba2d53ffcaabcc38261f7..247dc481c82b4f83e0771089cbc7bfcc27e8116a 100644
--- a/src/class-names/index.js
+++ b/src/class-names/index.js
@@ -2,6 +2,7 @@ import extractClassNames from './extractClassNames'
 import Hook from './hook'
 import dlv from 'dlv'
 import dset from 'dset'
+import resolveFrom from 'resolve-from'
 import importFrom from 'import-from'
 import chokidar from 'chokidar'
 import semver from 'semver'
@@ -55,13 +56,16 @@     })
     invariant(configPath.length === 1, 'No Tailwind CSS config found.')
     configPath = configPath[0]
     const configDir = path.dirname(configPath)
-    postcss = importFrom(configDir, 'postcss')
+    const tailwindBase = path.dirname(
+      resolveFrom(configDir, 'tailwindcss/package.json')
+    )
+    postcss = importFrom(tailwindBase, 'postcss')
     tailwindcss = importFrom(configDir, 'tailwindcss')
     version = importFrom(configDir, 'tailwindcss/package.json').version
 
     try {
       // this is not required
-      browserslistModule = importFrom(configDir, 'browserslist')
+      browserslistModule = importFrom(tailwindBase, 'browserslist')
     } catch (_) {}
 
     const sepLocation = semver.gte(version, '0.99.0')
M src/class-names/resolveConfig.js -> src/class-names/resolveConfig.js
diff --git a/src/class-names/resolveConfig.js b/src/class-names/resolveConfig.js
index ebd33cef749a337c6eaf48ce550a1f69175f5f8e..49a31546ef78ffbbec10b5d55dabb74b798a15e8 100644
--- a/src/class-names/resolveConfig.js
+++ b/src/class-names/resolveConfig.js
@@ -1,9 +1,13 @@
+import resolveFrom from 'resolve-from'
 import importFrom from 'import-from'
 import * as path from 'path'
 import decache from './decache'
 
 export default function resolveConfig({ cwd, config }) {
-  let resolve = x => x
+  const tailwindBase = path.dirname(
+    resolveFrom(cwd, 'tailwindcss/package.json')
+  )
+  let resolve = (x) => x
 
   if (typeof config === 'string') {
     if (!cwd) {
@@ -14,18 +18,18 @@     config = __non_webpack_require__(config)
   }
 
   try {
-    resolve = importFrom(cwd, 'tailwindcss/resolveConfig.js')
+    resolve = importFrom(tailwindBase, './resolveConfig.js')
   } catch (_) {
     try {
       const resolveConfig = importFrom(
-        cwd,
-        'tailwindcss/lib/util/resolveConfig.js'
+        tailwindBase,
+        './lib/util/resolveConfig.js'
       )
       const defaultConfig = importFrom(
-        cwd,
-        'tailwindcss/stubs/defaultConfig.stub.js'
+        tailwindBase,
+        './stubs/defaultConfig.stub.js'
       )
-      resolve = config => resolveConfig([config, defaultConfig])
+      resolve = (config) => resolveConfig([config, defaultConfig])
     } catch (_) {}
   }
 
M src/lsp/util/find.ts -> src/lsp/util/find.ts
diff --git a/src/lsp/util/find.ts b/src/lsp/util/find.ts
index 609de6207d066862bb645e4d9ca199c915010b61..12dde012f9aaa810475d97e78f202b05054f70d8 100644
--- a/src/lsp/util/find.ts
+++ b/src/lsp/util/find.ts
@@ -188,7 +188,7 @@               afterOffset
           )
 
           return {
-            classList: value,
+            classList: value.substr(beforeOffset, value.length + afterOffset),
             range: {
               start: {
                 line: (range?.start.line || 0) + start.line,