@@ -55,16 +55,19 @@ export default class DocumentSyncAdapter {
55
55
/**
56
56
* Public: Create a new {DocumentSyncAdapter} for the given language server.
57
57
*
58
- * @param connection A {LanguageClientConnection} to the language server to be kept in sync.
58
+ * @param _connection A {LanguageClientConnection} to the language server to be kept in sync.
59
59
* @param documentSync The document syncing options.
60
- * @param editorSelector A predicate function that takes a {TextEditor} and returns a {boolean} indicating whether
60
+ * @param _editorSelector A predicate function that takes a {TextEditor} and returns a {boolean} indicating whether
61
61
* this adapter should care about the contents of the editor.
62
+ * @param _getLanguageIdFromEditor A function that returns a {string} of `languageId` used for `textDocument/didOpen`
63
+ * notification.
62
64
*/
63
65
constructor (
64
66
private _connection : LanguageClientConnection ,
65
67
private _editorSelector : ( editor : TextEditor ) => boolean ,
66
68
documentSync : TextDocumentSyncOptions | TextDocumentSyncKind | undefined ,
67
- private _reportBusyWhile : Utils . ReportBusyWhile
69
+ private _reportBusyWhile : Utils . ReportBusyWhile ,
70
+ private _getLanguageIdFromEditor : ( editor : TextEditor ) => string
68
71
) {
69
72
if ( typeof documentSync === "object" ) {
70
73
this . _documentSync = documentSync
@@ -119,7 +122,8 @@ export default class DocumentSyncAdapter {
119
122
this . _connection ,
120
123
this . _documentSync ,
121
124
this . _versions ,
122
- this . _reportBusyWhile
125
+ this . _reportBusyWhile ,
126
+ this . _getLanguageIdFromEditor
123
127
)
124
128
this . _editors . set ( editor , sync )
125
129
this . _disposable . add ( sync )
@@ -149,16 +153,17 @@ export class TextEditorSyncAdapter {
149
153
/**
150
154
* Public: Create a {TextEditorSyncAdapter} in sync with a given language server.
151
155
*
152
- * @param editor A {TextEditor} to keep in sync.
153
- * @param connection A {LanguageClientConnection} to a language server to keep in sync.
154
- * @param documentSync The document syncing options.
156
+ * @param _editor A {TextEditor} to keep in sync.
157
+ * @param _connection A {LanguageClientConnection} to a language server to keep in sync.
158
+ * @param _documentSync The document syncing options.
155
159
*/
156
160
constructor (
157
161
private _editor : TextEditor ,
158
162
private _connection : LanguageClientConnection ,
159
163
private _documentSync : TextDocumentSyncOptions ,
160
164
private _versions : Map < string , number > ,
161
- private _reportBusyWhile : Utils . ReportBusyWhile
165
+ private _reportBusyWhile : Utils . ReportBusyWhile ,
166
+ private _getLanguageIdFromEditor : ( editor : TextEditor ) => string
162
167
) {
163
168
this . _fakeDidChangeWatchedFiles = atom . project . onDidChangeFiles == null
164
169
@@ -203,9 +208,9 @@ export class TextEditorSyncAdapter {
203
208
this . _disposable . dispose ( )
204
209
}
205
210
206
- /** Get the languageId field that will be sent to the language server by simply using the grammar name . */
211
+ /** Get the languageId field that will be sent to the language server by simply using the `_getLanguageIdFromEditor` . */
207
212
public getLanguageId ( ) : string {
208
- return this . _editor . getGrammar ( ) . name
213
+ return this . _getLanguageIdFromEditor ( this . _editor )
209
214
}
210
215
211
216
/**
0 commit comments