@@ -2,6 +2,7 @@ import { test, expect } from 'vitest'
2
2
import { withFixture } from '../common'
3
3
import { css , defineTest , html , js } from '../../src/testing'
4
4
import { createClient } from '../utils/client'
5
+ import { CompletionItemKind } from 'vscode-languageserver'
5
6
6
7
function buildCompletion ( c ) {
7
8
return async function completion ( {
@@ -798,3 +799,53 @@ defineTest({
798
799
expect ( completion ?. items . length ) . toBe ( 12289 )
799
800
} ,
800
801
} )
802
+
803
+ defineTest ( {
804
+ name : 'v4: Theme key completions show in var(…)' ,
805
+ fs : {
806
+ 'app.css' : css `
807
+ @import 'tailwindcss' ;
808
+
809
+ @theme {
810
+ --color-custom : # 000 ;
811
+ }
812
+ ` ,
813
+ } ,
814
+ prepare : async ( { root } ) => ( { client : await createClient ( { root } ) } ) ,
815
+ handle : async ( { client } ) => {
816
+ let document = await client . open ( {
817
+ settings : {
818
+ tailwindCSS : {
819
+ classFunctions : [ 'clsx' ] ,
820
+ } ,
821
+ } ,
822
+ lang : 'css' ,
823
+ text : css `
824
+ .foo {
825
+ color : var ();
826
+ }
827
+ ` ,
828
+ } )
829
+
830
+ // color: var();
831
+ // ^
832
+ let completion = await document . completions ( { line : 1 , character : 13 } )
833
+
834
+ expect ( completion ) . toEqual ( {
835
+ isIncomplete : false ,
836
+ items : expect . arrayContaining ( [
837
+ // From the default theme
838
+ expect . objectContaining ( { label : '--font-sans' } ) ,
839
+
840
+ // From the `@theme` block in the CSS file
841
+ expect . objectContaining ( {
842
+ label : '--color-custom' ,
843
+
844
+ // And it's shown as a color
845
+ kind : CompletionItemKind . Color ,
846
+ documentation : '#000000' ,
847
+ } ) ,
848
+ ] ) ,
849
+ } )
850
+ } ,
851
+ } )
0 commit comments