@@ -74,6 +74,7 @@ connection.onInitialize((params: InitializeParams) => {
7474 const result : InitializeResult = {
7575 capabilities : {
7676 textDocumentSync : TextDocumentSyncKind . Full ,
77+ documentFormattingProvider : true ,
7778 // Tell the client that this server supports code completion.
7879 // definitionProvider: false, //true
7980 // hoverProvider: false, //true
@@ -113,16 +114,6 @@ connection.onInitialized(() => {
113114
114115 connection . client . register ( DocumentFormattingRequest . type )
115116
116- connection . onDocumentFormatting ( ( _edits ) => {
117- const document = documents . get ( _edits . textDocument . uri )
118- if ( ! document ) {
119- console . log ( `Document not found.` )
120- return null
121- }
122-
123- return formatDocument ( document , _edits . options . tabSize )
124- } )
125-
126117 connection . client . register ( DidChangeConfigurationNotification . type )
127118
128119 if ( hasConfigurationCapability ) {
@@ -140,6 +131,16 @@ connection.onInitialized(() => {
140131 }
141132} ) ;
142133
134+ connection . onDocumentFormatting ( ( _edits ) => {
135+ const document = documents . get ( _edits . textDocument . uri )
136+ if ( ! document ) {
137+ console . log ( `Document not found.` )
138+ return null
139+ }
140+
141+ return formatDocument ( document , _edits . options . tabSize )
142+ } )
143+
143144// connection.onDidOpenTextDocument((params: DidOpenTextDocumentParams) => {
144145// const document = params.textDocument.text
145146// documents.set(params.textDocument.uri, params.textDocument.text)
0 commit comments