@@ -11,7 +11,7 @@ import type {
11
11
import type { TextDocument } from 'vscode-languageserver-textdocument'
12
12
import dlv from 'dlv'
13
13
import removeMeta from './util/removeMeta'
14
- import { getColor , getColorFromValue } from './util/color'
14
+ import { formatColor , getColor , getColorFromValue } from './util/color'
15
15
import { isHtmlContext } from './util/html'
16
16
import { isCssContext } from './util/css'
17
17
import { findLast , matchClassAttributes } from './util/find'
@@ -30,7 +30,6 @@ import { validateApply } from './util/validateApply'
30
30
import { flagEnabled } from './util/flagEnabled'
31
31
import * as jit from './util/jit'
32
32
import { getVariantsFromClassName } from './util/getVariantsFromClassName'
33
- import * as culori from 'culori'
34
33
import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
35
34
import {
36
35
addPixelEquivalentsToMediaQuery ,
@@ -42,14 +41,16 @@ let isUtil = (className) =>
42
41
? className . __info . some ( ( x ) => x . __source === 'utilities' )
43
42
: className . __info . __source === 'utilities'
44
43
45
- export function completionsFromClassList (
44
+ export async function completionsFromClassList (
46
45
state : State ,
46
+ document : TextDocument ,
47
47
classList : string ,
48
48
classListRange : Range ,
49
49
rootFontSize : number ,
50
50
filter ?: ( item : CompletionItem ) => boolean ,
51
51
context ?: CompletionContext
52
- ) : CompletionList {
52
+ ) : Promise < CompletionList > {
53
+ const settings = ( await state . editor . getConfiguration ( document . uri ) ) . tailwindCSS
53
54
let classNames = classList . split ( / [ \s + ] / )
54
55
const partialClassName = classNames [ classNames . length - 1 ]
55
56
let sep = state . separator
@@ -109,7 +110,7 @@ export function completionsFromClassList(
109
110
if ( color !== null ) {
110
111
kind = 16
111
112
if ( typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0 ) {
112
- documentation = culori . formatRgb ( color )
113
+ documentation = formatColor ( color , settings )
113
114
}
114
115
}
115
116
@@ -260,7 +261,7 @@ export function completionsFromClassList(
260
261
let documentation : string | undefined
261
262
262
263
if ( color && typeof color !== 'string' ) {
263
- documentation = culori . formatRgb ( color )
264
+ documentation = formatColor ( color , settings )
264
265
}
265
266
266
267
items . push ( {
@@ -307,7 +308,7 @@ export function completionsFromClassList(
307
308
if ( color !== null ) {
308
309
kind = 16
309
310
if ( typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0 ) {
310
- documentation = culori . formatRgb ( color )
311
+ documentation = formatColor ( color , settings )
311
312
}
312
313
}
313
314
@@ -393,7 +394,7 @@ export function completionsFromClassList(
393
394
if ( color !== null ) {
394
395
kind = 16
395
396
if ( typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0 ) {
396
- documentation = culori . formatRgb ( color )
397
+ documentation = formatColor ( color , settings )
397
398
}
398
399
}
399
400
@@ -466,8 +467,9 @@ async function provideClassAttributeCompletions(
466
467
}
467
468
}
468
469
469
- return completionsFromClassList (
470
+ return await completionsFromClassList (
470
471
state ,
472
+ document ,
471
473
classList ,
472
474
{
473
475
start : {
@@ -541,8 +543,9 @@ async function provideCustomClassNameCompletions(
541
543
classList = containerMatch [ 1 ] . substr ( 0 , cursor - matchStart )
542
544
}
543
545
544
- return completionsFromClassList (
546
+ return await completionsFromClassList (
545
547
state ,
548
+ document ,
546
549
classList ,
547
550
{
548
551
start : {
@@ -583,8 +586,9 @@ async function provideAtApplyCompletions(
583
586
584
587
const classList = match . groups . classList
585
588
586
- return completionsFromClassList (
589
+ return await completionsFromClassList (
587
590
state ,
591
+ document ,
588
592
classList ,
589
593
{
590
594
start : {
@@ -631,11 +635,11 @@ async function provideClassNameCompletions(
631
635
return null
632
636
}
633
637
634
- function provideCssHelperCompletions (
638
+ async function provideCssHelperCompletions (
635
639
state : State ,
636
640
document : TextDocument ,
637
641
position : Position
638
- ) : CompletionList {
642
+ ) : Promise < CompletionList > {
639
643
if ( ! isCssContext ( state , document , position ) ) {
640
644
return null
641
645
}
@@ -666,6 +670,7 @@ function provideCssHelperCompletions(
666
670
return null
667
671
}
668
672
673
+ const settings = ( await state . editor . getConfiguration ( document . uri ) ) . tailwindCSS
669
674
let base = match . groups . helper === 'config' ? state . config : dlv ( state . config , 'theme' , { } )
670
675
let parts = path . split ( / ( [ \[ \] . ] + ) / )
671
676
let keys = parts . filter ( ( _ , i ) => i % 2 === 0 )
@@ -744,7 +749,7 @@ function provideCssHelperCompletions(
744
749
// VS Code bug causes some values to not display in some cases
745
750
detail : detail === '0' || detail === 'transparent' ? `${ detail } ` : detail ,
746
751
...( color && typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0
747
- ? { documentation : culori . formatRgb ( color ) }
752
+ ? { documentation : formatColor ( color , settings ) }
748
753
: { } ) ,
749
754
...( insertClosingBrace ? { textEditText : `${ item } ]` } : { } ) ,
750
755
additionalTextEdits : replaceDot
@@ -1328,8 +1333,9 @@ async function provideEmmetCompletions(
1328
1333
const parts = emmetItems . items [ 0 ] . label . split ( '.' )
1329
1334
if ( parts . length < 2 ) return null
1330
1335
1331
- return completionsFromClassList (
1336
+ return await completionsFromClassList (
1332
1337
state ,
1338
+ document ,
1333
1339
parts [ parts . length - 1 ] ,
1334
1340
{
1335
1341
start : {
@@ -1352,7 +1358,7 @@ export async function doComplete(
1352
1358
1353
1359
const result =
1354
1360
( await provideClassNameCompletions ( state , document , position , context ) ) ||
1355
- provideCssHelperCompletions ( state , document , position ) ||
1361
+ ( await provideCssHelperCompletions ( state , document , position ) ) ||
1356
1362
provideCssDirectiveCompletions ( state , document , position ) ||
1357
1363
provideScreenDirectiveCompletions ( state , document , position ) ||
1358
1364
provideVariantsDirectiveCompletions ( state , document , position ) ||
0 commit comments