Skip to content

Commit 09a32d6

Browse files
committed
Add document links and completions for @source
source
1 parent b356886 commit 09a32d6

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,30 @@ withFixture('v4/basic', (c) => {
104104
},
105105
],
106106
})
107+
108+
testDocumentLinks('source: file exists', {
109+
text: '@source "index.html";',
110+
lang: 'css',
111+
expected: [
112+
{
113+
target: `file://${path
114+
.resolve('./tests/fixtures/v4/basic/index.html')
115+
.replace(/@/g, '%40')}`,
116+
range: { start: { line: 0, character: 8 }, end: { line: 0, character: 20 } },
117+
},
118+
],
119+
})
120+
121+
testDocumentLinks('source: file does not exist', {
122+
text: '@source "does-not-exist.html";',
123+
lang: 'css',
124+
expected: [
125+
{
126+
target: `file://${path
127+
.resolve('./tests/fixtures/v4/basic/does-not-exist.html')
128+
.replace(/@/g, '%40')}`,
129+
range: { start: { line: 0, character: 8 }, end: { line: 0, character: 29 } },
130+
},
131+
],
132+
})
107133
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ async function provideFileDirectiveCompletions(
15371537
}
15381538

15391539
let pattern = state.v4
1540-
? /@(config|plugin)\s*(?<partial>'[^']*|"[^"]*)$/
1540+
? /@(config|plugin|source)\s*(?<partial>'[^']*|"[^"]*)$/
15411541
: /@config\s*(?<partial>'[^']*|"[^"]*)$/
15421542

15431543
let text = document.getText({ start: { line: position.line, character: 0 }, end: position })

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function getDocumentLinks(
2020
if (state.v4) {
2121
patterns.push(
2222
/@plugin\s*(?<path>'[^']+'|"[^"]+")/g,
23+
/@source\s*(?<path>'[^']+'|"[^"]+")/g,
2324
)
2425
}
2526

0 commit comments

Comments
 (0)