@@ -17,6 +17,7 @@ export interface KnownNotifications {
17
17
export interface KnownRequests {
18
18
"window/showMessageRequest" : [ lsp . ShowMessageRequestParams , lsp . MessageActionItem | null ]
19
19
"workspace/applyEdit" : [ lsp . ApplyWorkspaceEditParams , lsp . ApplyWorkspaceEditResponse ]
20
+ [ custom : string ] : [ object , object | null ]
20
21
}
21
22
22
23
export type RequestCallback < T extends keyof KnownRequests > = KnownRequests [ T ] extends [ infer U , infer V ]
@@ -91,16 +92,32 @@ export class LanguageClientConnection extends EventEmitter {
91
92
}
92
93
93
94
/**
94
- * Public: Register a callback for a custom message.
95
+ * Public: Register a callback for a custom notification
95
96
*
96
97
* @param method A string containing the name of the message to listen for.
97
98
* @param callback The function to be called when the message is received.
98
99
* The payload from the message is passed to the function.
99
100
*/
100
- public onCustom ( method : string , callback : ( obj : object ) => void ) : void {
101
+ public onCustomNotification ( method : string , callback : ( obj : object ) => void ) : void {
101
102
this . _onNotification ( { method } , callback )
102
103
}
103
104
105
+ // @deprecated Use onCustomNotification method instead
106
+ public onCustom ( method : string , callback : ( obj : object ) => void ) : void {
107
+ this . onCustomNotification ( method , callback )
108
+ }
109
+
110
+ /**
111
+ * Public: Register a callback for a custom request
112
+ *
113
+ * @param method A string containing the name of the message to listen for.
114
+ * @param callback The function to be called when the message is received.
115
+ * The payload from the message is passed to the function.
116
+ */
117
+ public onCustomRequest ( method : string , callback : ( obj : object ) => Promise < object > ) : void {
118
+ this . _onRequest ( { method } , callback )
119
+ }
120
+
104
121
/**
105
122
* Public: Send a custom request
106
123
*
0 commit comments