@@ -26,11 +26,13 @@ export default class Extension {
2626 processor : Processor | undefined ;
2727 attrs : Attr [ 'static' ] ;
2828 colors : DictStr ;
29+ attrPrefix ?: string ;
2930 configFile ?: string ;
3031 variants : ResolvedVariants ;
3132 disposables : Disposable [ ] ;
3233 constructor ( ctx : ExtensionContext , pattern : GlobPattern ) {
3334 this . ctx = ctx ;
35+ this . attrPrefix = undefined ;
3436 this . pattern = pattern ;
3537 this . colors = { } ;
3638 this . attrs = { } ;
@@ -45,6 +47,7 @@ export default class Extension {
4547 this . jiti = jiti ( __filename ) ;
4648 this . configFile = files [ 0 ] ? files [ 0 ] . fsPath : undefined ;
4749 this . processor = new Processor ( this . loadConfig ( this . configFile ) ) as Processor ;
50+ this . attrPrefix = this . processor . config ( 'attributify.prefix' ) as string | undefined ;
4851 this . variants = this . processor . resolveVariants ( ) ;
4952 this . colors = flatColors ( this . processor . theme ( 'colors' , { } ) as colorObject ) ;
5053 this . register ( ) ;
@@ -224,12 +227,20 @@ export default class Extension {
224227 }
225228
226229 isAttrVariant ( word : string ) : boolean {
230+ if ( this . attrPrefix ) {
231+ if ( ! word . startsWith ( this . attrPrefix ) ) return false ;
232+ word = word . slice ( this . attrPrefix . length ) ;
233+ }
227234 const lastKey = word . match ( / [ ^ : - ] + $ / ) ?. [ 0 ] || word ;
228235 return getConfig ( 'windicss.enableAttrVariantCompletion' ) && lastKey in this . variants ;
229236 }
230237
231238 isAttrUtility ( word ?: string ) : string | undefined {
232239 if ( ! word ) return ;
240+ if ( this . attrPrefix ) {
241+ if ( ! word . startsWith ( this . attrPrefix ) ) return ;
242+ word = word . slice ( this . attrPrefix . length ) ;
243+ }
233244 const lastKey = word . match ( / [ ^ : - ] + $ / ) ?. [ 0 ] || word ;
234245 return getConfig ( 'windicss.enableAttrUtilityCompletion' ) && lastKey in this . attrs ? lastKey : undefined ;
235246 }
0 commit comments