@jupyterlab/lsp 4.6.0 → 4.7.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tokens.ts CHANGED
@@ -76,6 +76,93 @@ export type TSpecsMap = Map<TServerKeys, SCHEMA.LanguageServerSpec>;
76
76
  */
77
77
  export type TLanguageId = string;
78
78
 
79
+ /**
80
+ * @alpha
81
+ *
82
+ * Runtime language server session/spec provider.
83
+ */
84
+ export interface ILanguageServerProvider {
85
+ /**
86
+ * @alpha
87
+ *
88
+ * Provider identifier.
89
+ */
90
+ readonly id: string;
91
+
92
+ /**
93
+ * @alpha
94
+ *
95
+ * Signal emitted when provider sessions/specs are changed.
96
+ */
97
+ readonly sessionsChanged?: ISignal<ILanguageServerProvider, void>;
98
+
99
+ /**
100
+ * @alpha
101
+ *
102
+ * Fetch runtime language server data.
103
+ */
104
+ fetch(): Promise<ILanguageServerProvider.IFetchResult | null>;
105
+ }
106
+
107
+ export namespace ILanguageServerProvider {
108
+ /**
109
+ * Arguments used to create a transport for a specific language server.
110
+ */
111
+ export interface ITransportOptions {
112
+ /**
113
+ * Language server identifier.
114
+ */
115
+ languageServerId: TLanguageServerId;
116
+
117
+ /**
118
+ * Default websocket URL for the server.
119
+ */
120
+ socketUrl: string;
121
+
122
+ /**
123
+ * Jupyter server connection settings.
124
+ */
125
+ settings: ServerConnection.ISettings;
126
+ }
127
+
128
+ /**
129
+ * Transport factory for runtime language server connections.
130
+ */
131
+ export type TTransportFactory = (options: ITransportOptions) => WebSocket;
132
+
133
+ /**
134
+ * Per-server transport factories.
135
+ */
136
+ export interface ITransportFactoryMap {
137
+ [key: string]: TTransportFactory;
138
+ }
139
+
140
+ /**
141
+ * Runtime language server data contributed by a provider.
142
+ */
143
+ export interface IFetchResult {
144
+ /**
145
+ * Runtime sessions for language servers.
146
+ */
147
+ sessions?: TSessionMap | SCHEMA.Sessions;
148
+
149
+ /**
150
+ * Runtime specs for language servers.
151
+ */
152
+ specs?: TSpecsMap | SCHEMA.LanguageServerSpecsMap;
153
+
154
+ /**
155
+ * Provider status code.
156
+ */
157
+ statusCode?: number;
158
+
159
+ /**
160
+ * Optional transport factory/factories.
161
+ */
162
+ transport?: ITransportFactoryMap;
163
+ }
164
+ }
165
+
79
166
  export interface ILanguageServerManager extends IDisposable {
80
167
  /**
81
168
  * @alpha
@@ -91,6 +178,13 @@ export interface ILanguageServerManager extends IDisposable {
91
178
  */
92
179
  readonly sessions: TSessionMap;
93
180
 
181
+ /**
182
+ * @alpha
183
+ *
184
+ * The known language server specifications.
185
+ */
186
+ readonly specs: TSpecsMap;
187
+
94
188
  /**
95
189
  * @alpha
96
190
  *
@@ -143,7 +237,7 @@ export interface ILanguageServerManager extends IDisposable {
143
237
  /**
144
238
  * @alpha
145
239
  *
146
- * An ordered list of matching >running< sessions, with servers of higher rank higher in the list
240
+ * An ordered list of matching running sessions, with servers of higher rank higher in the list
147
241
  */
148
242
  getMatchingServers(
149
243
  options: ILanguageServerManager.IGetServerIdOptions
@@ -165,6 +259,22 @@ export interface ILanguageServerManager extends IDisposable {
165
259
  */
166
260
  setConfiguration(configuration: TLanguageServerConfigurations): void;
167
261
 
262
+ /**
263
+ * @alpha
264
+ *
265
+ * Register a runtime language server provider.
266
+ */
267
+ registerProvider?(provider: ILanguageServerProvider): IDisposable;
268
+
269
+ /**
270
+ * @alpha
271
+ *
272
+ * Get a runtime transport factory for a language server.
273
+ */
274
+ getTransportFactory(
275
+ languageServerId: TLanguageServerId
276
+ ): ILanguageServerProvider.TTransportFactory | null;
277
+
168
278
  /**
169
279
  * @alpha
170
280
  *
@@ -453,7 +563,8 @@ export interface ILSPDocumentConnectionManager {
453
563
 
454
564
  /**
455
565
  * Create a new connection to the language server
456
- * @return A promise of the LSP connection
566
+ *
567
+ * Returns a promise of the LSP connection.
457
568
  */
458
569
  connect(
459
570
  options: ISocketConnectionOptions,
@@ -622,7 +733,7 @@ export interface IWidgetLSPAdapterTracker<
622
733
  /**
623
734
  * Find the first instance in the tracker that satisfies a filter function.
624
735
  *
625
- * @param fn The filter function to call on each instance.
736
+ * @param fn - The filter function to call on each instance.
626
737
  *
627
738
  * #### Notes
628
739
  * If nothing is found, the value returned is `undefined`.
@@ -754,6 +865,7 @@ export namespace Method {
754
865
  COMPLETION = 'textDocument/completion',
755
866
  COMPLETION_ITEM_RESOLVE = 'completionItem/resolve',
756
867
  DEFINITION = 'textDocument/definition',
868
+ DIAGNOSTIC = 'textDocument/diagnostic',
757
869
  DOCUMENT_COLOR = 'textDocument/documentColor',
758
870
  DOCUMENT_HIGHLIGHT = 'textDocument/documentHighlight',
759
871
  DOCUMENT_SYMBOL = 'textDocument/documentSymbol',
@@ -825,6 +937,7 @@ export interface IClientRequestParams {
825
937
  [Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
826
938
  [Method.ClientRequest.COMPLETION]: lsp.CompletionParams;
827
939
  [Method.ClientRequest.DEFINITION]: lsp.TextDocumentPositionParams;
940
+ [Method.ClientRequest.DIAGNOSTIC]: lsp.DocumentDiagnosticParams;
828
941
  [Method.ClientRequest.DOCUMENT_COLOR]: lsp.DocumentColorParams;
829
942
  [Method.ClientRequest.DOCUMENT_HIGHLIGHT]: lsp.TextDocumentPositionParams;
830
943
  [Method.ClientRequest.DOCUMENT_SYMBOL]: lsp.DocumentSymbolParams;
@@ -835,6 +948,7 @@ export interface IClientRequestParams {
835
948
  [Method.ClientRequest.RENAME]: lsp.RenameParams;
836
949
  [Method.ClientRequest.SIGNATURE_HELP]: lsp.TextDocumentPositionParams;
837
950
  [Method.ClientRequest.TYPE_DEFINITION]: lsp.TextDocumentPositionParams;
951
+ [Method.ClientRequest.LINKED_EDITING_RANGE]: lsp.LinkedEditingRangeParams;
838
952
  [Method.ClientRequest.INLINE_VALUE]: lsp.InlineValueParams;
839
953
  [Method.ClientRequest.INLAY_HINT]: lsp.InlayHintParams;
840
954
  [Method.ClientRequest.WORKSPACE_SYMBOL]: lsp.WorkspaceSymbolParams;
@@ -851,6 +965,7 @@ export interface IClientResult {
851
965
  [Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
852
966
  [Method.ClientRequest.COMPLETION]: AnyCompletion;
853
967
  [Method.ClientRequest.DEFINITION]: AnyLocation;
968
+ [Method.ClientRequest.DIAGNOSTIC]: lsp.DocumentDiagnosticReport;
854
969
  [Method.ClientRequest.DOCUMENT_COLOR]: lsp.ColorInformation[];
855
970
  [Method.ClientRequest.DOCUMENT_HIGHLIGHT]: lsp.DocumentHighlight[];
856
971
  [Method.ClientRequest.DOCUMENT_SYMBOL]: lsp.DocumentSymbol[];
@@ -861,6 +976,7 @@ export interface IClientResult {
861
976
  [Method.ClientRequest.RENAME]: lsp.WorkspaceEdit;
862
977
  [Method.ClientRequest.SIGNATURE_HELP]: lsp.SignatureHelp;
863
978
  [Method.ClientRequest.TYPE_DEFINITION]: AnyLocation;
979
+ [Method.ClientRequest.LINKED_EDITING_RANGE]: lsp.LinkedEditingRanges | null;
864
980
  [Method.ClientRequest.INLINE_VALUE]: lsp.InlineValue[] | null;
865
981
  [Method.ClientRequest.INLAY_HINT]: lsp.InlayHint[] | null;
866
982
  [Method.ClientRequest.WORKSPACE_SYMBOL]:
@@ -1015,6 +1131,22 @@ export interface ILSPConnection extends ILspConnection, IObservableDisposable {
1015
1131
  */
1016
1132
  provides(capability: keyof lsp.ServerCapabilities): boolean;
1017
1133
 
1134
+ /**
1135
+ * @alpha
1136
+ *
1137
+ * Send a client request to the language server.
1138
+ *
1139
+ * @param method - The LSP method to request.
1140
+ * @param params - The parameters for the request.
1141
+ * @param options - Options for the request.
1142
+ * @returns The response from the language server.
1143
+ */
1144
+ request<M extends Method.ClientRequest>(
1145
+ method: M,
1146
+ params: IClientRequestParams[M],
1147
+ options?: ILSPConnection.IRequestOptions
1148
+ ): Promise<IClientResult[M]>;
1149
+
1018
1150
  /**
1019
1151
  * @alpha
1020
1152
  *
@@ -1044,3 +1176,15 @@ export interface ILSPConnection extends ILspConnection, IObservableDisposable {
1044
1176
  */
1045
1177
  sendFullTextChange(text: string, documentInfo: IDocumentInfo): void;
1046
1178
  }
1179
+
1180
+ export namespace ILSPConnection {
1181
+ /**
1182
+ * Options for an LSP request.
1183
+ */
1184
+ export interface IRequestOptions {
1185
+ /**
1186
+ * A signal used to cancel the request.
1187
+ */
1188
+ signal?: AbortSignal;
1189
+ }
1190
+ }