Skip to content

Commit beb6d43

Browse files
Improve CSS syntax highlighting (#1367)
Fixes #1340 Fixes #1250 This PR is intended to improve syntax highlighting for CSS. Currently things like `@plugin` are not always handled right, declarations inside `@theme` may be incorrectly tokenized — or even not at all, etc… **Proper nesting support will come in a separate PR** The best way to test this is to: - Clone the repo - Run the extension in the dev host - New file in the Tailwind CSS language mode - Toss in a bunch of CSS (can look at the tests for lots of stuff)
1 parent 78ee813 commit beb6d43

File tree

14 files changed

+4139
-41
lines changed

14 files changed

+4139
-41
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ jobs:
2626
- name: Install dependencies
2727
run: pnpm install
2828

29+
- name: Run syntax tests
30+
run: |
31+
cd packages/tailwindcss-language-syntax &&
32+
pnpm run build &&
33+
pnpm run test
34+
35+
- name: Run service tests
36+
run: |
37+
cd packages/tailwindcss-language-service &&
38+
pnpm run build &&
39+
pnpm run test
40+
2941
- name: Run tests
3042
run: |
3143
cd packages/tailwindcss-language-server &&

packages/tailwindcss-language-service/scripts/build.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { spawnSync } from 'node:child_process'
33
import esbuild from 'esbuild'
44
import minimist from 'minimist'
55
import { nodeExternalsPlugin } from 'esbuild-node-externals'
6+
import { fileURLToPath } from 'node:url'
67

7-
const __dirname = new URL('.', import.meta.url).pathname
8+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
89

910
const args = minimist(process.argv.slice(2), {
1011
boolean: ['watch', 'minify'],
@@ -30,7 +31,13 @@ let build = await esbuild.context({
3031
// Call the tsc command to generate the types
3132
spawnSync(
3233
'tsc',
33-
['-p', path.resolve(__dirname, './tsconfig.build.json'), '--emitDeclarationOnly', '--outDir', path.resolve(__dirname, '../dist')],
34+
[
35+
'-p',
36+
path.resolve(__dirname, './tsconfig.build.json'),
37+
'--emitDeclarationOnly',
38+
'--outDir',
39+
path.resolve(__dirname, '../dist'),
40+
],
3441
{
3542
stdio: 'inherit',
3643
},
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@tailwindcss/language-syntax",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"test": "vitest",
7+
"build": " "
8+
},
9+
"devDependencies": {
10+
"@types/node": "^18.19.33",
11+
"dedent": "^1.5.3",
12+
"vitest": "^3.1.4",
13+
"vscode-oniguruma": "^2.0.1",
14+
"vscode-textmate": "^9.2.0"
15+
}
16+
}

0 commit comments

Comments
 (0)