@@ -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 ] : [ Record < string , any > , Record < string , any > | null ]
20
21
}
21
22
22
23
export type RequestCallback < T extends keyof KnownRequests > = KnownRequests [ T ] extends [ infer U , infer V ]
@@ -91,16 +92,37 @@ 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
+ /**
106
+ * @deprecated Use `onCustomNotification` method instead
107
+ */
108
+ public onCustom ( method : string , callback : ( obj : object ) => void ) : void {
109
+ this . onCustomNotification ( method , callback )
110
+ }
111
+
112
+ /**
113
+ * Public: Register a callback for a custom request
114
+ *
115
+ * @param method A string containing the name of the message to listen for.
116
+ * @param callback The function to be called when the message is received.
117
+ * The payload from the message is passed to the function.
118
+ */
119
+ public onCustomRequest (
120
+ method : string ,
121
+ callback : ( obj : Record < string , any > ) => Promise < Record < string , any > | null >
122
+ ) : void {
123
+ this . _onRequest ( { method } , callback )
124
+ }
125
+
104
126
/**
105
127
* Public: Send a custom request
106
128
*
0 commit comments