@@ -11,6 +11,8 @@ interface DecorationMap {
1111 [ AnnotatorType . ReadOnlyLocal ] : vscode . TextEditorDecorationType ;
1212 [ AnnotatorType . MutLocal ] : vscode . TextEditorDecorationType ;
1313 [ AnnotatorType . MutParam ] : vscode . TextEditorDecorationType ;
14+ [ AnnotatorType . DocEm ] : vscode . TextEditorDecorationType ;
15+ [ AnnotatorType . DocStrong ] : vscode . TextEditorDecorationType ;
1416}
1517
1618// 装饰器缓存
@@ -30,12 +32,12 @@ const createDecoration = (key: string): vscode.TextEditorDecorationType => {
3032
3133 const config : vscode . DecorationRenderOptions = { } ;
3234 const color = vscode . workspace . getConfiguration ( "emmylua" ) . get < string > ( key ) ;
33-
35+
3436 if ( color ) {
3537 config . light = { color } ;
3638 config . dark = { color } ;
3739 }
38-
40+
3941 const decoration = vscode . window . createTextEditorDecorationType ( config ) ;
4042 decorationCache . set ( cacheKey , decoration ) ;
4143 return decoration ;
@@ -52,8 +54,8 @@ const createDecorationUnderline = (key: string): vscode.TextEditorDecorationType
5254
5355 const config : vscode . DecorationRenderOptions = { } ;
5456 const color = vscode . workspace . getConfiguration ( "emmylua" ) . get < string > ( key ) ;
55-
56- const textDecoration = color
57+
58+ const textDecoration = color
5759 ? `underline;text-decoration-color:${ color } ;text-underline-offset: 4px;`
5860 : 'underline;text-underline-offset: 4px;' ;
5961
@@ -64,7 +66,45 @@ const createDecorationUnderline = (key: string): vscode.TextEditorDecorationType
6466 config . light = { textDecoration } ;
6567 config . dark = { textDecoration } ;
6668 }
67-
69+
70+ const decoration = vscode . window . createTextEditorDecorationType ( config ) ;
71+ decorationCache . set ( cacheKey , decoration ) ;
72+ return decoration ;
73+ } ;
74+
75+ const createDecorationDocEm = ( ) : vscode . TextEditorDecorationType => {
76+ const cacheKey = `decoration:doc.em` ;
77+ if ( decorationCache . has ( cacheKey ) ) {
78+ return decorationCache . get ( cacheKey ) ! ;
79+ }
80+
81+ const config : vscode . DecorationRenderOptions = {
82+ light : {
83+ fontStyle : "italic" ,
84+ } ,
85+ dark : {
86+ fontStyle : "italic" ,
87+ } ,
88+ } ;
89+ const decoration = vscode . window . createTextEditorDecorationType ( config ) ;
90+ decorationCache . set ( cacheKey , decoration ) ;
91+ return decoration ;
92+ } ;
93+
94+ const createDecorationDocStrong = ( ) : vscode . TextEditorDecorationType => {
95+ const cacheKey = `decoration:doc.strong` ;
96+ if ( decorationCache . has ( cacheKey ) ) {
97+ return decorationCache . get ( cacheKey ) ! ;
98+ }
99+
100+ const config : vscode . DecorationRenderOptions = {
101+ light : {
102+ fontWeight : "bold" ,
103+ } ,
104+ dark : {
105+ fontWeight : "bold" ,
106+ } ,
107+ } ;
68108 const decoration = vscode . window . createTextEditorDecorationType ( config ) ;
69109 decorationCache . set ( cacheKey , decoration ) ;
70110 return decoration ;
@@ -107,6 +147,9 @@ const updateDecorations = (): void => {
107147 decorations [ AnnotatorType . MutLocal ] = createDecoration ( "colors.local" ) ;
108148 decorations [ AnnotatorType . MutParam ] = createDecoration ( "colors.parameter" ) ;
109149 }
150+
151+ decorations [ AnnotatorType . DocEm ] = createDecorationDocEm ( ) ;
152+ decorations [ AnnotatorType . DocStrong ] = createDecorationDocStrong ( ) ;
110153} ;
111154
112155/**
@@ -142,13 +185,13 @@ const requestAnnotatorsImpl = async (editor: vscode.TextEditor, client: Language
142185 updateDecorations ( ) ;
143186 }
144187
145- const params : notifications . AnnotatorParams = {
146- uri : editor . document . uri . toString ( )
188+ const params : notifications . AnnotatorParams = {
189+ uri : editor . document . uri . toString ( )
147190 } ;
148191
149192 try {
150193 const annotationList = await client . sendRequest < notifications . IAnnotator [ ] > ( "emmy/annotator" , params ) ;
151-
194+
152195 if ( ! annotationList ) {
153196 return ;
154197 }
@@ -159,7 +202,9 @@ const requestAnnotatorsImpl = async (editor: vscode.TextEditor, client: Language
159202 [ AnnotatorType . Global , [ ] ] ,
160203 [ AnnotatorType . ReadOnlyLocal , [ ] ] ,
161204 [ AnnotatorType . MutLocal , [ ] ] ,
162- [ AnnotatorType . MutParam , [ ] ]
205+ [ AnnotatorType . MutParam , [ ] ] ,
206+ [ AnnotatorType . DocEm , [ ] ] ,
207+ [ AnnotatorType . DocStrong , [ ] ] ,
163208 ] ) ;
164209
165210 // 批量处理注释
@@ -183,8 +228,8 @@ const requestAnnotatorsImpl = async (editor: vscode.TextEditor, client: Language
183228 * 更新编辑器中特定类型的注释器
184229 */
185230const updateAnnotators = (
186- editor : vscode . TextEditor ,
187- type : AnnotatorType ,
231+ editor : vscode . TextEditor ,
232+ type : AnnotatorType ,
188233 ranges : vscode . Range [ ]
189234) : void => {
190235 const decoration = decorations [ type ] ;
@@ -206,7 +251,7 @@ export const dispose = (): void => {
206251 // 清理所有装饰器
207252 disposeDecorations ( ...Object . values ( decorations ) ) ;
208253 decorations = { } ;
209-
254+
210255 // 清理缓存中的装饰器
211256 decorationCache . forEach ( decoration => decoration . dispose ( ) ) ;
212257 decorationCache . clear ( ) ;
0 commit comments