Skip to content

Commit 9a57535

Browse files
committed
Add support for more CSS directive completions
wip wpi
1 parent 34ee91d commit 9a57535

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

packages/tailwindcss-language-server/src/language/cssServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
381381
.filter((diagnostic) => {
382382
if (
383383
diagnostic.code === 'unknownAtRules' &&
384-
/Unknown at rule @(tailwind|apply|config|theme|plugin|source)/.test(diagnostic.message)
384+
/Unknown at rule @(tailwind|apply|config|theme|plugin|source|utility|variant)/.test(diagnostic.message)
385385
) {
386386
return false
387387
}

packages/tailwindcss-language-service/src/completionProvider.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ function provideCssDirectiveCompletions(
14851485
})
14861486
}
14871487

1488-
if (semver.gte(state.version, '4.0.0')) {
1488+
if (state.v4) {
14891489
items.push({
14901490
label: '@theme',
14911491
documentation: {
@@ -1496,6 +1496,50 @@ function provideCssDirectiveCompletions(
14961496
)})`,
14971497
},
14981498
})
1499+
1500+
items.push({
1501+
label: '@utility',
1502+
documentation: {
1503+
kind: 'markdown' as typeof MarkupKind.Markdown,
1504+
value: `Use the \`@utility\` directive to define a custom utility.\n\n[Tailwind CSS Documentation](${docsUrl(
1505+
state.version,
1506+
'functions-and-directives/#utility',
1507+
)})`,
1508+
},
1509+
})
1510+
1511+
items.push({
1512+
label: '@variant',
1513+
documentation: {
1514+
kind: 'markdown' as typeof MarkupKind.Markdown,
1515+
value: `Use the \`@variant\` directive to define a custom variant or override an existing one.\n\n[Tailwind CSS Documentation](${docsUrl(
1516+
state.version,
1517+
'functions-and-directives/#variant',
1518+
)})`,
1519+
},
1520+
})
1521+
1522+
items.push({
1523+
label: '@source',
1524+
documentation: {
1525+
kind: 'markdown' as typeof MarkupKind.Markdown,
1526+
value: `Use the \`@source\` directive to scan additional files for classes.\n\n[Tailwind CSS Documentation](${docsUrl(
1527+
state.version,
1528+
'functions-and-directives/#source',
1529+
)})`,
1530+
},
1531+
})
1532+
1533+
items.push({
1534+
label: '@plugin',
1535+
documentation: {
1536+
kind: 'markdown' as typeof MarkupKind.Markdown,
1537+
value: `Use the \`@plugin\` directive to include a JS plugin in your Tailwind CSS build.\n\n[Tailwind CSS Documentation](${docsUrl(
1538+
state.version,
1539+
'functions-and-directives/#source',
1540+
)})`,
1541+
},
1542+
})
14991543
}
15001544

15011545
return withDefaults(

0 commit comments

Comments
 (0)