Skip to content

Commit 2bcf851

Browse files
committed
Make v4 theme key hovers nicer
1 parent e0b5f73 commit 2bcf851

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

packages/tailwindcss-language-server/tests/hover/hover.test.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,14 @@ withFixture('v4/basic', (c) => {
399399
expected: {
400400
contents: {
401401
kind: 'markdown',
402-
value: ['```plaintext', '80rem /* 1280px */', '```'].join('\n'),
402+
value: [
403+
//
404+
'```css',
405+
'@theme {',
406+
' --breakpoint-xl: 80rem /* 1280px */;',
407+
'}',
408+
'```',
409+
].join('\n'),
403410
},
404411
range: {
405412
start: { line: 0, character: 23 },
@@ -582,7 +589,14 @@ defineTest({
582589
expect(hoverTheme).toEqual({
583590
contents: {
584591
kind: 'markdown',
585-
value: ['```plaintext', '#000', '```'].join('\n'),
592+
value: [
593+
//
594+
'```css',
595+
'@theme {',
596+
' --color-black: #000;',
597+
'}',
598+
'```',
599+
].join('\n'),
586600
},
587601
range: {
588602
start: { line: 1, character: 15 },
@@ -593,7 +607,14 @@ defineTest({
593607
expect(hoverVar).toEqual({
594608
contents: {
595609
kind: 'markdown',
596-
value: ['```plaintext', '#000', '```'].join('\n'),
610+
value: [
611+
//
612+
'```css',
613+
'@theme {',
614+
' --color-black: #000;',
615+
'}',
616+
'```',
617+
].join('\n'),
597618
},
598619
range: {
599620
start: { line: 4, character: 13 },

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

+11
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ async function provideCssHelperHover(
7171

7272
let lines = ['```plaintext', value, '```']
7373

74+
if (state.v4 && helperFn.path.startsWith('--')) {
75+
lines = [
76+
//
77+
'```css',
78+
'@theme {',
79+
` ${helperFn.path}: ${value};`,
80+
'}',
81+
'```',
82+
]
83+
}
84+
7485
return {
7586
contents: { kind: 'markdown', value: lines.join('\n') },
7687
range: helperFn.ranges.path,

0 commit comments

Comments
 (0)