Skip to content

Commit 1a46ede

Browse files
committed
Detect paths in source() directives
1 parent 2672c70 commit 1a46ede

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/tailwindcss-language-server/tests/document-links/document-links.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,22 @@ withFixture('v4/basic', (c) => {
130130
},
131131
],
132132
})
133+
134+
testDocumentLinks('Directories in source(…) show links', {
135+
text: `
136+
@import "tailwindcss" source("../../");
137+
@tailwind utilities source("../../");
138+
`,
139+
lang: 'css',
140+
expected: [
141+
{
142+
target: `file://${path.resolve('./tests/fixtures').replace(/@/g, '%40')}`,
143+
range: { start: { line: 1, character: 35 }, end: { line: 1, character: 43 } },
144+
},
145+
{
146+
target: `file://${path.resolve('./tests/fixtures').replace(/@/g, '%40')}`,
147+
range: { start: { line: 2, character: 33 }, end: { line: 2, character: 41 } },
148+
},
149+
],
150+
})
133151
})

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

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export function getDocumentLinks(
2222
patterns.push(
2323
/@plugin\s*(?<path>'[^']+'|"[^"]+")/g,
2424
/@source\s*(?<path>'[^']+'|"[^"]+")/g,
25+
/@import\s*('[^']*'|"[^"]*")\s*source\((?<path>'[^']*'?|"[^"]*"?)/g,
26+
/@tailwind\s*utilities\s*source\((?<path>'[^']*'?|"[^"]*"?)/g,
2527
)
2628
}
2729

0 commit comments

Comments
 (0)