@@ -8,7 +8,7 @@ import { registerTS } from 'sucrase/dist/register';
88import type { Core } from '../interfaces' ;
99import { Log } from '../utils/Log' ;
1010
11- export async function init ( ) :Promise < Core > {
11+ export async function init ( ) : Promise < Core > {
1212 try {
1313 const files = await workspace . findFiles ( '{tailwind,windi}.config.{js,cjs,ts}' , '**/node_modules/**' ) ;
1414 let configFile ;
@@ -22,7 +22,7 @@ export async function init():Promise<Core> {
2222 if ( mod . default ) config = mod . default ;
2323 } else {
2424 delete require . cache [ require . resolve ( resolve ( configFile ) ) ] ;
25- config = require ( resolve ( configFile ) ) ;
25+ config = import ( resolve ( configFile ) ) ;
2626 }
2727 Log . info ( `Loading Config File: ${ configFile } ` ) ;
2828 }
@@ -42,53 +42,52 @@ export async function init():Promise<Core> {
4242 } ) ;
4343
4444 let staticCompletions = Object . keys ( staticUtilities ) ;
45- const colorCompletions : { label : string , detail : string , documentation : string } [ ] = [ ] ;
46- const dynamicCompletions : { label : string , position : number } [ ] = [ ] ;
45+ const colorCompletions : { label : string , detail : string , documentation : string } [ ] = [ ] ;
46+ const dynamicCompletions : { label : string , position : number } [ ] = [ ] ;
4747
4848 for ( const [ config , list ] of Object . entries ( dynamic ) ) {
4949 list . forEach ( utility => {
5050 const mark = utility . search ( / \$ / ) ;
5151 if ( mark === - 1 ) {
5252 staticCompletions . push ( utility ) ;
5353 } else {
54- const prefix = utility . slice ( 0 , mark - 1 ) ;
54+ const prefix = utility . slice ( 0 , mark - 1 ) ;
5555 const suffix = utility . slice ( mark ) ;
56- switch ( suffix ) {
57- case '${static}' :
58- const staticConfig = Object . keys ( processor . theme ( config , { } ) as any ) ;
59- const complections = staticConfig . map ( i => i === 'DEFAULT' ? prefix : i . charAt ( 0 ) === '-' ? `-${ prefix } ${ i } ` : `${ prefix } -${ i } ` ) ;
60- // if (config in negative) complections = complections.concat(complections.map(i => `-${i}`));
61- staticCompletions = staticCompletions . concat ( complections ) ;
62- break ;
63- case '${color}' :
64- const colorConfig = flatColors ( processor . theme ( config , colors ) as any ) ;
65- for ( const [ k , v ] of Object . entries ( colorConfig ) ) {
66- const name = `${ prefix } -${ k } ` ;
67- const color = Array . isArray ( v ) ? v [ 0 ] : v ;
68- colorCompletions . push ( {
69- label : name ,
70- detail : processor . interpret ( name ) . styleSheet . build ( ) ,
71- documentation : [ 'transparent' , 'currentColor' ] . includes ( color ) ? color : `rgb(${ hex2RGB ( color ) ?. join ( ', ' ) } )` ,
72- } ) ;
73- }
74- break ;
75- default :
76- dynamicCompletions . push ( {
77- label : utility ,
78- position : utility . length - mark ,
79- } ) ;
80- if ( config in negative ) {
56+ switch ( suffix ) {
57+ case '${static}' :
58+ const staticConfig = Object . keys ( processor . theme ( config , { } ) as any ) ;
59+ const complections = staticConfig . map ( i => i === 'DEFAULT' ? prefix : i . charAt ( 0 ) === '-' ? `-${ prefix } ${ i } ` : `${ prefix } -${ i } ` ) ;
60+ // if (config in negative) complections = complections.concat(complections.map(i => `-${i}`));
61+ staticCompletions = staticCompletions . concat ( complections ) ;
62+ break ;
63+ case '${color}' :
64+ const colorConfig = flatColors ( processor . theme ( config , colors ) as any ) ;
65+ for ( const [ k , v ] of Object . entries ( colorConfig ) ) {
66+ const name = `${ prefix } -${ k } ` ;
67+ const color = Array . isArray ( v ) ? v [ 0 ] : v ;
68+ colorCompletions . push ( {
69+ label : name ,
70+ detail : processor . interpret ( name ) . styleSheet . build ( ) ,
71+ documentation : [ 'transparent' , 'currentColor' ] . includes ( color ) ? color : `rgb(${ hex2RGB ( color ) ?. join ( ', ' ) } )` ,
72+ } ) ;
73+ }
74+ break ;
75+ default :
8176 dynamicCompletions . push ( {
82- label : `- ${ utility } ` ,
83- position : utility . length + 1 - mark ,
77+ label : utility ,
78+ position : utility . length - mark ,
8479 } ) ;
85- }
86- break ;
80+ if ( config in negative ) {
81+ dynamicCompletions . push ( {
82+ label : `-${ utility } ` ,
83+ position : utility . length + 1 - mark ,
84+ } ) ;
85+ }
86+ break ;
8787 }
8888 }
8989 } ) ;
9090 }
91-
9291 return {
9392 processor,
9493 colors,
0 commit comments