File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,27 @@ export async function setupLs(modelsMap: Ref<Map<string, monaco.editor.ITextMode
422422 }
423423 } ,
424424 } ) ,
425+ monaco . languages . registerOnTypeFormattingEditProvider ( lang , {
426+ autoFormatTriggerCharacters : [ '}' , ';' , '\n' ] ,
427+ provideOnTypeFormattingEdits : async ( model , position , ch , options ) => {
428+ const document = documents . get ( model ) ;
429+ if ( document ) {
430+ const codeResult = await ds . format (
431+ document ,
432+ monaco2code . asFormattingOptions ( options ) ,
433+ undefined ,
434+ {
435+ ch : ch ,
436+ position : monaco2code . asPosition ( position ) ,
437+ } ,
438+ ) ;
439+ if ( codeResult ) {
440+ return codeResult . map ( code2monaco . asTextEdit ) ;
441+ }
442+ }
443+ return [ ] ;
444+ } ,
445+ } ) ,
425446 monaco . languages . registerCompletionItemProvider ( lang , {
426447 // https://github.com/johnsoncodehk/volar/blob/2f786182250d27e99cc3714fbfc7d209616e2289/packages/vue-language-server/src/registers/registerlanguageFeatures.ts#L57
427448 triggerCharacters : '!@#$%^&*()_+-=`~{}|[]\:";\'<>?,./ ' . split ( '' ) ,
You can’t perform that action at this time.
0 commit comments