tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
support css properties with multiple values
5 changed files, 63 additions(+), 8 deletions(-)
diff --git a/packages/tailwindcss-class-names/src/extractClassNames.mjs b/packages/tailwindcss-class-names/src/extractClassNames.mjs
index 4ccb6622101ef1538bfffa21842e3265d0706a23..df4559939aba242c977b6be4adea01cfe05adb47 100644
--- a/packages/tailwindcss-class-names/src/extractClassNames.mjs
+++ b/packages/tailwindcss-class-names/src/extractClassNames.mjs
@@ -55,8 +55,17 @@ const classNames = getClassNamesFromSelector(rule.selector)
const decls = {}
rule.walkDecls((decl) => {
+ if (decls[decl.prop]) {
+ decls[decl.prop] = [
+ ...(Array.isArray(decls[decl.prop])
+ ? decls[decl.prop]
+ : [decls[decl.prop]]),
+ decl.value,
+ }
import dset from 'dset'
-function createSelectorFromNodes(nodes) {
+ } else {
+ decls[decl.prop] = decl.value
+ }
})
let p = rule
diff --git a/packages/tailwindcss-class-names/tests/extractClassNames.test.js b/packages/tailwindcss-class-names/tests/extractClassNames.test.js
index 7e7b6471ff2ee0ba50de454d6743490a152e5e01..fe8e04bf6ba717f7e2e1a52a79b06cca78fbbe7a 100644
--- a/packages/tailwindcss-class-names/tests/extractClassNames.test.js
+++ b/packages/tailwindcss-class-names/tests/extractClassNames.test.js
@@ -350,3 +350,24 @@ ],
},
})
})
+
+test('processes multiple properties of the same name', async () => {
+ const result = await processCss(`
+ .bg-red {
+ background-color: blue;
+ background-color: red;
+ }
+ `)
+
+ expect(result).toEqual({
+ context: {},
+ classNames: {
+ 'bg-red': {
+ __rule: true,
+ __context: [],
+ __scope: null,
+ 'background-color': ['blue', 'red'],
+ },
+ },
+ })
+})
diff --git a/packages/tailwindcss-language-server/src/providers/completionProvider.ts b/packages/tailwindcss-language-server/src/providers/completionProvider.ts
index 54f39076f9ee0da598c03d4a503699dcf66520ee..bb78423a37f7e2c8d48fed37d4f45413bf782113 100644
--- a/packages/tailwindcss-language-server/src/providers/completionProvider.ts
+++ b/packages/tailwindcss-language-server/src/providers/completionProvider.ts
@@ -23,6 +23,7 @@ import { isJsContext } from '../util/js'
import { naturalExpand } from '../util/naturalExpand'
import semver from 'semver'
import { docsUrl } from '../util/docsUrl'
+import { ensureArray } from '../util/array'
function completionsFromClassList(
state: State,
@@ -726,12 +727,22 @@ }
function stringifyDecls(obj: any): string {
CompletionItem,
- documentation,
+ { context, position, textDocument }: CompletionParams
+ let nonCustomProps = props.filter((prop) => !prop.startsWith('--'))
+
+ if (props.length !== nonCustomProps.length && nonCustomProps.length !== 0) {
+ props = nonCustomProps
+ }
+
+ ...classListRange,
CompletionItem,
- command,
- let replacementRange = {
+ CompletionItemKind,
+ CompletionItemKind,
- let replacementRange = {
+ ensureArray(obj[prop])
+ .map((value) => `${prop}: ${value};`)
+ .join(' ')
import { State } from '../util/state'
+import { isCssContext } from '../util/css'
.join(' ')
}
diff --git a/packages/tailwindcss-language-server/src/util/array.ts b/packages/tailwindcss-language-server/src/util/array.ts
new file mode 100644
index 0000000000000000000000000000000000000000..13683ccbd6c9bb53185ebb57311e5833d551c5c5
--- /dev/null
+++ b/packages/tailwindcss-language-server/src/util/array.ts
@@ -0,0 +1,11 @@
+export function dedupe<T>(arr: Array<T>): Array<T> {
+ return arr.filter((value, index, self) => self.indexOf(value) === index)
+}
+
+export function ensureArray<T>(value: T | T[]): T[] {
+ return Array.isArray(value) ? value : [value]
+}
+
+export function flatten<T>(arrays: T[][]): T[] {
+ return [].concat.apply([], arrays)
+}
diff --git a/packages/tailwindcss-language-server/src/util/stringify.ts b/packages/tailwindcss-language-server/src/util/stringify.ts
index 5433e90926433db92e6f14389dd4c1d796df38a3..f2811a6b93276f3bdab86c4f1084af6ce56489a0 100644
--- a/packages/tailwindcss-language-server/src/util/stringify.ts
+++ b/packages/tailwindcss-language-server/src/util/stringify.ts
@@ -2,6 +2,8 @@ import removeMeta from './removeMeta'
const dlv = require('dlv')
import escapeClassName from 'css.escape'
+export function stringifyConfigValue(x: any): string {
+
export function stringifyConfigValue(x: any): string {
if (typeof x === 'string') return x
if (typeof x === 'number') return x.toString()
@@ -35,9 +37,10 @@ }
const indentStr = '\t'.repeat(context.length)
const decls = props.reduce((acc, curr, i) => {
- return `${acc}${i === 0 ? '' : '\n'}${indentStr + '\t'}${curr}: ${
+ const propStr = ensureArray(obj[curr])
- obj[curr]
+ .map((val) => `${indentStr + '\t'}${curr}: ${val};`)
+ .join('\n')
- };`
+ return `${acc}${i === 0 ? '' : '\n'}${propStr}`
}, '')
css += `${indentStr}${augmentClassName(
className,