@@ -12,6 +12,7 @@ import {
12
12
WorkspaceFolder ,
13
13
Disposable ,
14
14
ConfigurationRequest ,
15
+ CompletionItemKind ,
15
16
} from 'vscode-languageserver/node'
16
17
import { TextDocument } from 'vscode-languageserver-textdocument'
17
18
import { Utils , URI } from 'vscode-uri'
@@ -143,15 +144,40 @@ async function withDocumentAndSettings<T>(
143
144
}
144
145
145
146
connection . onCompletion ( async ( { textDocument, position } , _token ) =>
146
- withDocumentAndSettings ( textDocument . uri , ( { document, settings } ) =>
147
- cssLanguageService . doComplete2 (
147
+ withDocumentAndSettings ( textDocument . uri , async ( { document, settings } ) => {
148
+ let result = await cssLanguageService . doComplete2 (
148
149
document ,
149
150
position ,
150
151
stylesheets . get ( document ) ,
151
152
getDocumentContext ( document . uri , workspaceFolders ) ,
152
153
settings ?. completion
153
154
)
154
- )
155
+ return {
156
+ isIncomplete : result . isIncomplete ,
157
+ items : result . items . flatMap ( ( item ) => {
158
+ // Add the `theme()` function
159
+ if ( item . kind === CompletionItemKind . Function && item . label === 'calc()' ) {
160
+ return [
161
+ item ,
162
+ {
163
+ ...item ,
164
+ label : 'theme()' ,
165
+ documentation : {
166
+ kind : 'markdown' ,
167
+ value :
168
+ 'Use the `theme()` function to access your Tailwind config values using dot notation.' ,
169
+ } ,
170
+ textEdit : {
171
+ ...item . textEdit ,
172
+ newText : item . textEdit . newText . replace ( / ^ c a l c \( / , 'theme(' ) ,
173
+ } ,
174
+ } ,
175
+ ]
176
+ }
177
+ return item
178
+ } ) ,
179
+ }
180
+ } )
155
181
)
156
182
157
183
connection . onHover ( ( { textDocument, position } , _token ) =>
0 commit comments