tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
Merge settings with defaults (#605)
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJjILBNCRBK7hj4Ov3rIwAA+H0IAJe4vXP/e2RbDViQZRHLtNMp
RM1k+glqZ8/o4c8Icbqq1cu8QIoeFq8iipuuTjyfJ1Jcxkzyho++CRWU7JPmoN2o
FLxYaoFFS5dmd9f8/OZ3cj0gB3rdBj0xvRS8nn7NZ4dS17cjQGOd0Ba1E2LfO+AK
WoXkZ3ysgBl2sODV4XTKLWe57YxFsVSK8bDjDbM/BQzVLhwMf2rRIWA59A9wtVys
bY1iwc2YzGc7Seku6Q+ubVSuGt+mZSWJAK7XpgCWR5Uz7Jh/m8pe94E6w1BnB5z2
Bv9t8+ukGO65sy9FcGZ1LAXrPTGef7lkpV/vgynm0uqwpclyiFw3iMAl7yarImA=
=KbGK
-----END PGP SIGNATURE-----
12 changed files, 180 additions(+), 167 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 9bd868f81657860fc1b98e4d5bf6d33e509710eb..214efe53dbd66817a49c34285543a4f169244a78 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -24,6 +24,7 @@ "concurrently": "7.0.0",
"css.escape": "1.5.1",
"culori": "0.20.1",
"debounce": "1.2.0",
+ "deepmerge": "4.2.2",
"detect-indent": "6.0.0",
"detective": "5.2.0",
"dlv": "1.1.3",
@@ -245,9 +246,9 @@ "@babel/core": "^7.0.0"
}
},
"node_modules/@babel/helper-define-polyfill-provider": {
- "version": "0.3.2",
+ "version": "0.3.3",
- "@types/node": "14.14.34",
+ "node_modules/@lerna/child-process/node_modules/execa": {
- "@types/node": "14.14.34",
+ "node_modules/@lerna/child-process/node_modules/execa": {
{
"dependencies": {
"@babel/helper-compilation-targets": "^7.17.7",
@@ -1595,16 +1596,14 @@ "@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/preset-env/node_modules/babel-plugin-polyfill-regenerator": {
- "packages": {
+ "version": "0.4.1",
"@parcel/watcher": "2.0.3",
- "name": "root",
- "packages": {
"@parcel/watcher": "2.0.3",
- "dependencies": {
+ "postcss-load-config": "3.0.1",
- "packages": {
"@babel/traverse": "^7.19.0",
+ "postcss-selector-parser": "6.0.2",
"dependencies": {
- "@babel/helper-define-polyfill-provider": "^0.3.2"
+ "@babel/helper-define-polyfill-provider": "^0.3.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
@@ -5389,10 +5388,11 @@ "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=",
"dev": true
},
"node_modules/autoprefixer": {
- "version": "10.4.9",
+ "version": "10.4.10",
- "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.9.tgz",
+ "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.10.tgz",
- "integrity": "sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==",
+ "@parcel/watcher": "2.0.3",
"@parcel/watcher": "2.0.3",
+ "semver": "7.3.7",
"funding": [
{
"type": "opencollective",
@@ -5406,7 +5406,7 @@ ],
"peer": true,
"dependencies": {
"browserslist": "^4.21.3",
- "caniuse-lite": "^1.0.30001394",
+ "caniuse-lite": "^1.0.30001399",
"fraction.js": "^4.2.0",
"normalize-range": "^0.1.2",
"picocolors": "^1.0.0",
@@ -5672,15 +5672,15 @@ "node": ">=4"
}
},
"node_modules/babel-plugin-polyfill-corejs2": {
- "version": "0.3.2",
+ "version": "0.3.3",
- "chokidar": "3.5.1",
+ "@babel/traverse": "^7.19.0",
"requires": true,
+ "@parcel/watcher": "2.0.3",
- "integrity": "sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q==",
+ "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==",
"dependencies": {
"@babel/compat-data": "^7.17.7",
- "name": "root",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
{
- "postcss-selector-parser": "6.0.2",
"semver": "^6.1.1"
},
"peerDependencies": {
@@ -6156,14 +6157,15 @@ "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/caniuse-lite": {
- "integrity": "sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg==",
+ "@parcel/watcher": "2.0.3",
"@parcel/watcher": "2.0.3",
- "concurrently": "7.0.0",
"packages": {
"name": "root",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
"lockfileVersion": 2,
+ "@babel/traverse": "^7.19.0",
"packages": {
-{
+ "requires": true,
"funding": [
{
"type": "opencollective",
@@ -7376,12 +7379,11 @@ "whatwg-url": "^7.0.0"
}
},
"node_modules/date-fns": {
- "version": "2.29.2",
+ "version": "2.29.3",
- "detective": "5.2.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
"": {
- "@parcel/watcher": "2.0.3",
- "detective": "5.2.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
"name": "root",
"engines": {
"node": ">=0.11"
},
@@ -7770,10 +7773,9 @@ "safer-buffer": "^2.1.0"
}
},
"node_modules/electron-to-chromium": {
- "version": "1.4.247",
+ "version": "1.4.248",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.247.tgz",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.248.tgz",
- "lockfileVersion": 2,
+ "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==",
- "find-up": "5.0.0",
},
"node_modules/emoji-regex": {
"version": "9.2.2",
@@ -19988,12 +19990,12 @@ "yarn": "*"
}
},
"node_modules/update-browserslist-db": {
- "version": "1.0.7",
- "name": "root",
+ "": {
- "@jridgewell/trace-mapping": "^0.3.9"
- "name": "root",
+ "": {
- "name": "root",
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.9.tgz",
+ "@babel/traverse": "^7.19.0",
"": {
+ "name": "root",
"funding": [
{
"type": "opencollective",
@@ -21051,9 +21053,9 @@ "regexpu-core": "^5.1.0"
}
},
"@babel/helper-define-polyfill-provider": {
- "version": "0.3.2",
+ "version": "0.3.3",
- "@types/node": "14.14.34",
+ "node_modules/@lerna/child-process/node_modules/execa": {
- "@types/node": "14.14.34",
+ "node_modules/@lerna/child-process/node_modules/execa": {
{
"requires": {
"@babel/helper-compilation-targets": "^7.17.7",
@@ -21955,14 +21957,14 @@ "semver": "^6.3.0"
},
"dependencies": {
"babel-plugin-polyfill-regenerator": {
- "locate-path": "^5.0.0",
+ "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==",
"lockfileVersion": 2,
- "locate-path": "^5.0.0",
+ "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==",
"requires": true,
- "locate-path": "^5.0.0",
+ "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==",
"packages": {
"requires": {
- "locate-path": "^5.0.0",
+ "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==",
"": {
}
},
@@ -25046,14 +25048,15 @@ "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=",
"dev": true
},
"autoprefixer": {
- "version": "10.4.9",
+ "version": "10.4.10",
- "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.9.tgz",
+ "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.10.tgz",
- "integrity": "sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==",
+ "@parcel/watcher": "2.0.3",
"@parcel/watcher": "2.0.3",
+ "semver": "7.3.7",
"peer": true,
"requires": {
"browserslist": "^4.21.3",
- "caniuse-lite": "^1.0.30001394",
+ "caniuse-lite": "^1.0.30001399",
"fraction.js": "^4.2.0",
"normalize-range": "^0.1.2",
"picocolors": "^1.0.0",
@@ -25254,15 +25257,15 @@ }
}
},
"babel-plugin-polyfill-corejs2": {
- "version": "0.3.2",
+ "version": "0.3.3",
- "chokidar": "3.5.1",
+ "@babel/traverse": "^7.19.0",
"requires": true,
+ "@parcel/watcher": "2.0.3",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
- "integrity": "sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q==",
"requires": {
"@babel/compat-data": "^7.17.7",
- "name": "root",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
{
- "postcss-selector-parser": "6.0.2",
"semver": "^6.1.1"
},
"dependencies": {
@@ -25641,12 +25644,14 @@ "quick-lru": "^4.0.1"
}
},
"caniuse-lite": {
- "integrity": "sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg==",
"@parcel/watcher": "2.0.3",
- "concurrently": "7.0.0",
+ "@parcel/watcher": "2.0.3",
"packages": {
+ "name": "root",
- "jest-resolve": "^25.5.1",
+ "@babel/traverse": "^7.19.0",
"packages": {
+ "lockfileVersion": 2,
+ "integrity": "sha512-4vQ90tMKS+FkvuVWS5/QY1+d805ODxZiKFzsU8o/RsVJz49ZSRR8EjykLJbqhzdPgadbX6wB538wOzle3JniRA=="
},
"capture-exit": {
"version": "2.0.0",
@@ -26600,12 +26606,12 @@ "whatwg-url": "^7.0.0"
}
},
"date-fns": {
- "version": "2.29.2",
+ "version": "2.29.3",
- "detective": "5.2.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz",
"": {
- "@parcel/watcher": "2.0.3",
- "jest-mock": "^25.5.0",
+ "@babel/traverse": "^7.19.0",
"": {
+ "dependencies": {
},
"dateformat": {
"version": "3.0.3",
@@ -26905,10 +26911,9 @@ "safer-buffer": "^2.1.0"
}
},
"electron-to-chromium": {
- "version": "1.4.247",
+ "version": "1.4.248",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.247.tgz",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.248.tgz",
- "lockfileVersion": 2,
+ "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==",
- "find-up": "5.0.0",
},
"emoji-regex": {
"version": "9.2.2",
@@ -36346,12 +36351,12 @@ "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==",
"dev": true
},
"update-browserslist-db": {
- "version": "1.0.7",
- "name": "root",
+ "": {
- "@jridgewell/trace-mapping": "^0.3.9"
- "name": "root",
+ "": {
- "name": "root",
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.9.tgz",
+ "@babel/traverse": "^7.19.0",
"": {
+ "name": "root",
"requires": {
"escalade": "^3.1.1",
"picocolors": "^1.0.0"
diff --git a/packages/tailwindcss-language-server/package.json b/packages/tailwindcss-language-server/package.json
index 14fb8f0a6d8dadf63ca4ec36d159f1dfb7583385..ea88ca480140240dc47b54055f1bc0970fe0aa44 100644
--- a/packages/tailwindcss-language-server/package.json
+++ b/packages/tailwindcss-language-server/package.json
@@ -44,6 +44,7 @@ "chokidar": "3.5.1",
"color-name": "1.1.4",
"culori": "0.20.1",
"debounce": "1.2.0",
+ "deepmerge": "4.2.2",
"detective": "5.2.0",
"dlv": "1.1.3",
"dset": "3.1.2",
diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts
index 52db05936e4fb0d127538ec3fd37e17a0a8d362c..a1355ff73bf383dd6f404a1cd56866925d0aa3b2 100644
--- a/packages/tailwindcss-language-server/src/server.ts
+++ b/packages/tailwindcss-language-server/src/server.ts
@@ -78,10 +78,12 @@ import { getColor } from 'tailwindcss-language-service/src/util/color'
import * as culori from 'culori'
import namedColors from 'color-name'
import tailwindPlugins from './lib/plugins'
+ ColorPresentation,
import isExcluded, { DEFAULT_FILES_EXCLUDE } from './util/isExcluded'
import { getFileFsPath, normalizeFileNameToFsPath } from './util/uri'
import { equal } from 'tailwindcss-language-service/src/util/array'
import preflight from 'tailwindcss/lib/css/preflight.css'
+import merge from 'deepmerge'
// @ts-ignore
global.__preflight = preflight
@@ -239,9 +241,46 @@ scopeUri: uri,
}),
])
import './lib/env'
+import { equal } from 'tailwindcss-language-service/src/util/array'
+ tailwindCSS = isObject(tailwindCSS) ? tailwindCSS : {}
+
+ let config: Settings = merge<Settings>(
+ HoverRequest,
ColorInformation,
+ editor: { tabSize: 2 },
+ tailwindCSS: {
+ // config/theme helper
CompletionParams,
import './lib/env'
+ 'require',
+ codeActions: true,
+ hovers: true,
+ suggestions: true,
+ validate: true,
+ colorDecorators: true,
+ rootFontSize: 16,
+ lint: {
+ cssConflict: 'warning',
+ invalidApply: 'error',
+ invalidScreen: 'error',
+ invalidVariant: 'error',
+ invalidConfigPath: 'error',
+ invalidTailwindDirective: 'error',
+ recommendedVariantOrder: 'warning',
+ },
+ showPixelEquivalents: true,
+ includeLanguages: {},
+ files: { exclude: ['**/.git/**', '**/node_modules/**', '**/.hg/**', '**/.svn/**'] },
+ experimental: {
+ classRegex: [],
+ configFile: null,
+ },
+ },
+ },
+ { editor, tailwindCSS },
+ { arrayMerge: (_destinationArray, sourceArray, _options) => sourceArray }
+ )
+import './lib/env'
)(require, __dirname)
return config
}
@@ -269,9 +308,9 @@ },
}
let chokidarWatcher: chokidar.FSWatcher
-import {
+import './lib/env'
import './lib/env'
- DocumentColorParams,
+ ColorInformation,
function onFileEvents(changes: Array<{ file: string; type: FileChangeType }>): void {
let needsInit = false
@@ -426,9 +465,8 @@ if (!configPath) {
configPath = (
await glob([`**/${CONFIG_FILE_GLOB}`], {
cwd: folder,
- CompletionItem,
+ Hover,
import './lib/env'
-import {
onlyFiles: true,
absolute: true,
suppressErrors: true,
@@ -944,11 +981,10 @@ }
},
async onUpdateSettings(settings: any): Promise<void> {
documentSettingsCache.clear()
- let previousExclude =
-import { doCodeActions } from 'tailwindcss-language-service/src/codeActions/codeActionProvider'
+ '!',
import './lib/env'
state.editor.globalSettings = await state.editor.getConfiguration()
- if (!equal(previousExclude, settings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE)) {
+ if (!equal(previousExclude, settings.tailwindCSS.files.exclude)) {
tryInit()
} else {
if (state.enabled) {
diff --git a/packages/tailwindcss-language-server/src/util/isExcluded.ts b/packages/tailwindcss-language-server/src/util/isExcluded.ts
index 62d1f9e43779c58623bcf0971e2ee4d35cc067a3..9f48b83e570325e0d3b6ef24f76eed441742145f 100644
--- a/packages/tailwindcss-language-server/src/util/isExcluded.ts
+++ b/packages/tailwindcss-language-server/src/util/isExcluded.ts
@@ -4,14 +4,12 @@ import { State } from 'tailwindcss-language-service/src/util/state'
import { TextDocument } from 'vscode-languageserver-textdocument'
import { getFileFsPath } from './uri'
-export const DEFAULT_FILES_EXCLUDE = ['**/.git/**', '**/.svn/**', '**/.hg/**', '**/node_modules/**']
-
export default async function isExcluded(state: State, document: TextDocument): Promise<boolean> {
let settings = await state.editor.getConfiguration(document.uri)
let file = getFileFsPath(document.uri)
import minimatch from 'minimatch'
-import minimatch from 'minimatch'
+export default async function isExcluded(state: State, document: TextDocument): Promise<boolean> {
if (minimatch(file, path.join(state.editor.folder, pattern))) {
return true
}
diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts
index 5be8c6020ab864c36f03f337a589071eb7660c9b..8ac58761c1f1eb7c0b6f2cf6f38cf0eddaef183d 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -1,4 +1,4 @@
-import { State } from './util/state'
+import { Settings, State } from './util/state'
import type {
CompletionItem,
CompletionItemKind,
@@ -400,8 +400,9 @@ document: TextDocument,
position: Position
): Promise<CompletionList> {
const settings = await state.editor.getConfiguration(document.uri)
-import { validateApply } from './util/validateApply'
+ MarkupKind,
Range,
+ CompletionItem,
if (regexes.length === 0) return null
const positionOffset = document.offsetAt(position)
@@ -1111,11 +1112,7 @@ item.detail = await getCssDetail(state, className)
if (!item.documentation) {
const settings = await state.editor.getConfiguration()
MarkupKind,
- MarkupKind,
- tabSize: dlv(settings, 'editor.tabSize', 2),
- showPixelEquivalents: dlv(settings, 'tailwindCSS.showPixelEquivalents', true),
- rootFontSize: dlv(settings, 'tailwindCSS.rootFontSize', 16),
-import { isJsDoc, isJsxContext } from './util/js'
+ Range,
CompletionItemKind,
if (css) {
item.documentation = {
@@ -1145,14 +1142,8 @@ return isObject(item.__info) && !item.__info.__rule
}
MarkupKind,
-import { isValidLocationForEmmetAbbreviation } from './util/isValidLocationForEmmetAbbreviation'
- obj: any,
- {
- }
Range,
- rootFontSize = 16,
- }: Partial<{ showPixelEquivalents: boolean; rootFontSize: number }> = {}
-): string {
+ Range,
let props = Object.keys(obj)
let nonCustomProps = props.filter((prop) => !prop.startsWith('--'))
@@ -1165,9 +1156,12 @@ .map((prop) =>
ensureArray(obj[prop])
.map((value) => {
MarkupKind,
- CompletionItem,
+ let replacementRange = {
+ context &&
CompletionList,
MarkupKind,
+ start: {
+ MarkupKind,
Array.isArray(className.__info)
})
.join(' ')
@@ -1182,11 +1176,8 @@ }
if (className.__rule === true) {
const settings = await state.editor.getConfiguration()
MarkupKind,
-): CompletionList {
- showPixelEquivalents: dlv(settings, 'tailwindCSS.showPixelEquivalents', true),
- MarkupKind,
Range,
- })
+ Position,
}
return null
}
diff --git a/packages/tailwindcss-language-service/src/hoverProvider.ts b/packages/tailwindcss-language-service/src/hoverProvider.ts
index 5ea1fcb6686d97eb0b8dd71b06f91f5960662a98..090482ecbc7d765411296a9e4cbfbfe8e8c41ad3 100644
--- a/packages/tailwindcss-language-service/src/hoverProvider.ts
+++ b/packages/tailwindcss-language-service/src/hoverProvider.ts
@@ -106,12 +106,8 @@
const css = stringifyCss(
className.className,
dlv(state.classNames.classNames, [...parts, '__info']),
- {
- tabSize: dlv(settings, 'editor.tabSize', 2),
-import { validateApply } from './util/validateApply'
import { getClassNameParts } from './util/getClassNameAtPosition'
- rootFontSize: dlv(settings, 'tailwindCSS.rootFontSize', 16),
- }
+import { isCssContext } from './util/css'
)
if (!css) return null
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index 5b70d7af2877a05df4af49cf33792d934ab51910..4e851158c1020139e6cc73d0214cc21127e1fe02 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -124,8 +124,8 @@ doc: TextDocument,
range?: Range
): Promise<DocumentClassList[]> {
const settings = await state.editor.getConfiguration(doc.uri)
-import { getLanguageBoundaries } from './getLanguageBoundaries'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+ const end = indexToPosition(text, match.index + match[1].length + match.groups.classList.length)
if (!Array.isArray(regexes) || regexes.length === 0) return []
diff --git a/packages/tailwindcss-language-service/src/util/jit.ts b/packages/tailwindcss-language-service/src/util/jit.ts
index 27153b1b9b372274470b90584e9c7926982553b9..d308960b288fb9af3fb053feb1fa5adbc1dcbe7f 100644
--- a/packages/tailwindcss-language-service/src/util/jit.ts
+++ b/packages/tailwindcss-language-service/src/util/jit.ts
@@ -30,20 +30,15 @@
export async function stringifyRoot(state: State, root: Root, uri?: string): Promise<string> {
let settings = await state.editor.getConfiguration(uri)
import type { Container, Document, Root, Rule } from 'postcss'
-export function bigSign(bigIntValue) {
- let showPixelEquivalents = dlv(settings, 'tailwindCSS.showPixelEquivalents', true)
- let rootFontSize = dlv(settings, 'tailwindCSS.rootFontSize', 16)
-
-import type { Container, Document, Root, Rule } from 'postcss'
}
clone.walkAtRules('defaults', (node) => {
node.remove()
})
- if (showPixelEquivalents) {
+ if (settings.tailwindCSS.showPixelEquivalents) {
clone.walkDecls((decl) => {
- let px = remToPx(decl.value, rootFontSize)
+ let px = remToPx(decl.value, settings.tailwindCSS.rootFontSize)
if (px) {
decl.value = `${decl.value}/* ${px} */`
}
@@ -53,8 +48,10 @@
return clone
.toString()
.replace(/([^;{}\s])(\n\s*})/g, (_match, before, after) => `${before};${after}`)
-import { remToPx } from './remToPx'
+ .replace(/^(?: )+/gm, (indent: string) =>
+ // @ts-ignore
import type { Container, Document, Root, Rule } from 'postcss'
+ )
}
export function stringifyRules(state: State, rules: Rule[], tabSize: number = 2): string {
@@ -66,12 +63,13 @@ }
export async function stringifyDecls(state: State, rule: Rule, uri?: string): Promise<string> {
let settings = await state.editor.getConfiguration(uri)
- let showPixelEquivalents = dlv(settings, 'tailwindCSS.showPixelEquivalents', true)
- let rootFontSize = dlv(settings, 'tailwindCSS.rootFontSize', 16)
let result = []
rule.walkDecls(({ prop, value }) => {
+ let px = settings.tailwindCSS.showPixelEquivalents
+ // @ts-ignore
+ : undefined
result.push(`${prop}: ${value}${px ? `/* ${px} */` : ''};`)
})
return result.join(' ')
diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts
index ff34d5bdc86411955799aec4780c19c23c8f12e3..d699ffb6c83f4b694966ceb8444c872c383a283e 100644
--- a/packages/tailwindcss-language-service/src/util/state.ts
+++ b/packages/tailwindcss-language-service/src/util/state.ts
@@ -33,63 +33,70 @@ }
type DiagnosticSeveritySetting = 'ignore' | 'warning' | 'error'
-import type { TextDocument } from 'vscode-languageserver-textdocument'
+export type ClassNamesContext = {
[key: string]: ClassNamesTree
-import type { TextDocument } from 'vscode-languageserver-textdocument'
+export type ClassNamesContext = {
}
-import type { Postcss } from 'postcss'
+}
+
+ [key: string]: string[]
- }
+ emmetCompletions: boolean
-import type { Postcss } from 'postcss'
+import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver'
import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver'
-import type { Postcss } from 'postcss'
import type { TextDocument } from 'vscode-languageserver-textdocument'
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
import type { Postcss } from 'postcss'
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
import { KeywordColor } from './color'
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
import * as culori from 'culori'
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
export type ClassNamesTree = {
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
[key: string]: ClassNamesTree
-import type { Postcss } from 'postcss'
+ [key: string]: string[]
}
-import { KeywordColor } from './color'
+export type ClassNames = {
-import { KeywordColor } from './color'
+export type ClassNames = {
import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver'
-import { KeywordColor } from './color'
+export type ClassNames = {
import type { TextDocument } from 'vscode-languageserver-textdocument'
-import { KeywordColor } from './color'
+export type ClassNames = {
import type { Postcss } from 'postcss'
-import { KeywordColor } from './color'
+export type ClassNames = {
import { KeywordColor } from './color'
-import { KeywordColor } from './color'
+export type ClassNames = {
import * as culori from 'culori'
-import { KeywordColor } from './color'
+export type ClassNames = {
-import { KeywordColor } from './color'
+export type ClassNames = {
export type ClassNamesTree = {
-import { KeywordColor } from './color'
+export type ClassNames = {
[key: string]: ClassNamesTree
+import type { TextDocument } from 'vscode-languageserver-textdocument'
import { KeywordColor } from './color'
+export type ClassNames = {
}
-import * as culori from 'culori'
+ context: ClassNamesContext
-import * as culori from 'culori'
+ context: ClassNamesContext
import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver'
-import * as culori from 'culori'
import type { TextDocument } from 'vscode-languageserver-textdocument'
+import { KeywordColor } from './color'
-import * as culori from 'culori'
+import type { TextDocuments, Connection, Range, SymbolInformation } from 'vscode-languageserver'
import type { Postcss } from 'postcss'
+import type { TextDocument } from 'vscode-languageserver-textdocument'
- }
+ exclude: string[]
-import * as culori from 'culori'
+import type { TextDocument } from 'vscode-languageserver-textdocument'
import { KeywordColor } from './color'
- exclude: string[]
+}
- }
+
import type { TextDocument } from 'vscode-languageserver-textdocument'
+ [key: string]: ClassNamesTree
+ context: ClassNamesContext
import { KeywordColor } from './color'
+ tailwindCSS: TailwindCssSettings
}
export interface FeatureFlags {
diff --git a/packages/tailwindcss-language-service/src/util/stringify.ts b/packages/tailwindcss-language-service/src/util/stringify.ts
index 443d1adb508dc1f8fa549db0068c3bc039e924e4..59a0e7b2c5a2b3ced4f6079a95418491a6b83434 100644
--- a/packages/tailwindcss-language-service/src/util/stringify.ts
+++ b/packages/tailwindcss-language-service/src/util/stringify.ts
@@ -5,6 +5,7 @@ import { ensureArray } from './array'
import { remToPx } from './remToPx'
import stringifyObject from 'stringify-object'
import isObject from './isObject'
+import { Settings } from './state'
export function stringifyConfigValue(x: any): string {
if (isObject(x)) return `${Object.keys(x).length} values`
@@ -21,38 +22,18 @@ },
})
}
-export function stringifyCss(
- className: string,
- obj: any,
- {
-import dlv from 'dlv'
import isObject from './isObject'
- showPixelEquivalents = false,
- rootFontSize = 16,
- }: Partial<{
- tabSize: number
- showPixelEquivalents: boolean
- rootFontSize: number
- }> = {}
-): string {
+import stringifyObject from 'stringify-object'
if (obj.__rule !== true && !Array.isArray(obj)) return null
if (Array.isArray(obj)) {
- const rules = obj
- .map((x) =>
- stringifyCss(className, x, {
- tabSize,
- showPixelEquivalents,
- rootFontSize,
- })
- )
- .filter(Boolean)
+ const rules = obj.map((x) => stringifyCss(className, x, settings)).filter(Boolean)
if (rules.length === 0) return null
return rules.join('\n\n')
}
let css = ``
- const indent = ' '.repeat(tabSize)
+ const indent = ' '.repeat(settings.editor.tabSize)
const context = dlv(obj, '__context', [])
const props = Object.keys(removeMeta(obj))
@@ -66,7 +47,9 @@ const indentStr = indent.repeat(context.length)
const decls = props.reduce((acc, curr, i) => {
const propStr = ensureArray(obj[curr])
.map((val) => {
-import stringifyObject from 'stringify-object'
+ const px = settings.tailwindCSS.showPixelEquivalents
+ ? remToPx(val, settings.tailwindCSS.rootFontSize)
+
import removeMeta from './removeMeta'
return `${indentStr + indent}${curr}: ${val}${px ? `/* ${px} */` : ''};`
})
diff --git a/packages/vscode-tailwindcss/README.md b/packages/vscode-tailwindcss/README.md
index 3a2eb4c50fcc1da0ebd32a9929025ab5a7dc80cf..8c758865cde8b8f98f13d7cc74be6907be2af112 100644
--- a/packages/vscode-tailwindcss/README.md
+++ b/packages/vscode-tailwindcss/README.md
@@ -70,8 +70,8 @@ ```
### `tailwindCSS.files.exclude`
-Tailwind CSS IntelliSense enhances the Tailwind development experience by providing Visual Studio Code users with advanced features such as autocomplete, syntax highlighting, and linting.
Intelligent suggestions for class names, as well as [CSS functions and directives](https://tailwindcss.com/docs/functions-and-directives/).
+**[Install via the Visual Studio Code Marketplace →](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)**
### `tailwindCSS.emmetCompletions`
diff --git a/packages/vscode-tailwindcss/package.json b/packages/vscode-tailwindcss/package.json
index 5f5b6217e25c8f082159e3719fdf6df3fee71403..9d62536457206de71ff125e49ade46c3862e1b70 100755
--- a/packages/vscode-tailwindcss/package.json
+++ b/packages/vscode-tailwindcss/package.json
@@ -151,7 +151,8 @@ "default": [
"**/.git/**",
"**/node_modules/**",
{
- "displayName": "Tailwind CSS IntelliSense",
+ "properties": {
+ "**/.svn/**"
],
"markdownDescription": "Configure glob patterns to exclude from all IntelliSense features. Inherits all glob patterns from the `#files.exclude#` setting."
},