@@ -11,7 +11,7 @@ import type {
1111import type { TextDocument } from 'vscode-languageserver-textdocument'
1212import dlv from 'dlv'
1313import removeMeta from './util/removeMeta'
14- import { getColor , getColorFromValue } from './util/color'
14+ import { formatColor , getColor , getColorFromValue } from './util/color'
1515import { isHtmlContext } from './util/html'
1616import { isCssContext } from './util/css'
1717import { findLast , matchClassAttributes } from './util/find'
@@ -30,7 +30,6 @@ import { validateApply } from './util/validateApply'
3030import { flagEnabled } from './util/flagEnabled'
3131import * as jit from './util/jit'
3232import { getVariantsFromClassName } from './util/getVariantsFromClassName'
33- import * as culori from 'culori'
3433import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
3534import {
3635 addPixelEquivalentsToMediaQuery ,
@@ -42,14 +41,16 @@ let isUtil = (className) =>
4241 ? className . __info . some ( ( x ) => x . __source === 'utilities' )
4342 : className . __info . __source === 'utilities'
4443
45- export function completionsFromClassList (
44+ export async function completionsFromClassList (
4645 state : State ,
46+ document : TextDocument ,
4747 classList : string ,
4848 classListRange : Range ,
4949 rootFontSize : number ,
5050 filter ?: ( item : CompletionItem ) => boolean ,
5151 context ?: CompletionContext
52- ) : CompletionList {
52+ ) : Promise < CompletionList > {
53+ const settings = ( await state . editor . getConfiguration ( document . uri ) ) . tailwindCSS
5354 let classNames = classList . split ( / [ \s + ] / )
5455 const partialClassName = classNames [ classNames . length - 1 ]
5556 let sep = state . separator
@@ -109,7 +110,7 @@ export function completionsFromClassList(
109110 if ( color !== null ) {
110111 kind = 16
111112 if ( typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0 ) {
112- documentation = culori . formatRgb ( color )
113+ documentation = formatColor ( color , settings )
113114 }
114115 }
115116
@@ -260,7 +261,7 @@ export function completionsFromClassList(
260261 let documentation : string | undefined
261262
262263 if ( color && typeof color !== 'string' ) {
263- documentation = culori . formatRgb ( color )
264+ documentation = formatColor ( color , settings )
264265 }
265266
266267 items . push ( {
@@ -307,7 +308,7 @@ export function completionsFromClassList(
307308 if ( color !== null ) {
308309 kind = 16
309310 if ( typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0 ) {
310- documentation = culori . formatRgb ( color )
311+ documentation = formatColor ( color , settings )
311312 }
312313 }
313314
@@ -393,7 +394,7 @@ export function completionsFromClassList(
393394 if ( color !== null ) {
394395 kind = 16
395396 if ( typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0 ) {
396- documentation = culori . formatRgb ( color )
397+ documentation = formatColor ( color , settings )
397398 }
398399 }
399400
@@ -466,8 +467,9 @@ async function provideClassAttributeCompletions(
466467 }
467468 }
468469
469- return completionsFromClassList (
470+ return await completionsFromClassList (
470471 state ,
472+ document ,
471473 classList ,
472474 {
473475 start : {
@@ -541,8 +543,9 @@ async function provideCustomClassNameCompletions(
541543 classList = containerMatch [ 1 ] . substr ( 0 , cursor - matchStart )
542544 }
543545
544- return completionsFromClassList (
546+ return await completionsFromClassList (
545547 state ,
548+ document ,
546549 classList ,
547550 {
548551 start : {
@@ -583,8 +586,9 @@ async function provideAtApplyCompletions(
583586
584587 const classList = match . groups . classList
585588
586- return completionsFromClassList (
589+ return await completionsFromClassList (
587590 state ,
591+ document ,
588592 classList ,
589593 {
590594 start : {
@@ -631,11 +635,11 @@ async function provideClassNameCompletions(
631635 return null
632636}
633637
634- function provideCssHelperCompletions (
638+ async function provideCssHelperCompletions (
635639 state : State ,
636640 document : TextDocument ,
637641 position : Position
638- ) : CompletionList {
642+ ) : Promise < CompletionList > {
639643 if ( ! isCssContext ( state , document , position ) ) {
640644 return null
641645 }
@@ -666,6 +670,7 @@ function provideCssHelperCompletions(
666670 return null
667671 }
668672
673+ const settings = ( await state . editor . getConfiguration ( document . uri ) ) . tailwindCSS
669674 let base = match . groups . helper === 'config' ? state . config : dlv ( state . config , 'theme' , { } )
670675 let parts = path . split ( / ( [ \[ \] . ] + ) / )
671676 let keys = parts . filter ( ( _ , i ) => i % 2 === 0 )
@@ -744,7 +749,7 @@ function provideCssHelperCompletions(
744749 // VS Code bug causes some values to not display in some cases
745750 detail : detail === '0' || detail === 'transparent' ? `${ detail } ` : detail ,
746751 ...( color && typeof color !== 'string' && ( color . alpha ?? 1 ) !== 0
747- ? { documentation : culori . formatRgb ( color ) }
752+ ? { documentation : formatColor ( color , settings ) }
748753 : { } ) ,
749754 ...( insertClosingBrace ? { textEditText : `${ item } ]` } : { } ) ,
750755 additionalTextEdits : replaceDot
@@ -1328,8 +1333,9 @@ async function provideEmmetCompletions(
13281333 const parts = emmetItems . items [ 0 ] . label . split ( '.' )
13291334 if ( parts . length < 2 ) return null
13301335
1331- return completionsFromClassList (
1336+ return await completionsFromClassList (
13321337 state ,
1338+ document ,
13331339 parts [ parts . length - 1 ] ,
13341340 {
13351341 start : {
@@ -1352,7 +1358,7 @@ export async function doComplete(
13521358
13531359 const result =
13541360 ( await provideClassNameCompletions ( state , document , position , context ) ) ||
1355- provideCssHelperCompletions ( state , document , position ) ||
1361+ ( await provideCssHelperCompletions ( state , document , position ) ) ||
13561362 provideCssDirectiveCompletions ( state , document , position ) ||
13571363 provideScreenDirectiveCompletions ( state , document , position ) ||
13581364 provideVariantsDirectiveCompletions ( state , document , position ) ||
0 commit comments