@jupyterlab/lsp 4.0.0-alpha.11

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.
Files changed (51) hide show
  1. package/lib/adapters/adapter.d.ts +125 -0
  2. package/lib/adapters/adapter.js +382 -0
  3. package/lib/adapters/adapter.js.map +1 -0
  4. package/lib/connection.d.ts +65 -0
  5. package/lib/connection.js +309 -0
  6. package/lib/connection.js.map +1 -0
  7. package/lib/connection_manager.d.ts +71 -0
  8. package/lib/connection_manager.js +312 -0
  9. package/lib/connection_manager.js.map +1 -0
  10. package/lib/extractors/manager.d.ts +13 -0
  11. package/lib/extractors/manager.js +44 -0
  12. package/lib/extractors/manager.js.map +1 -0
  13. package/lib/extractors/text_extractor.d.ts +28 -0
  14. package/lib/extractors/text_extractor.js +27 -0
  15. package/lib/extractors/text_extractor.js.map +1 -0
  16. package/lib/extractors/types.d.ts +65 -0
  17. package/lib/extractors/types.js +2 -0
  18. package/lib/extractors/types.js.map +1 -0
  19. package/lib/feature.d.ts +11 -0
  20. package/lib/feature.js +31 -0
  21. package/lib/feature.js.map +1 -0
  22. package/lib/index.d.ts +17 -0
  23. package/lib/index.js +22 -0
  24. package/lib/index.js.map +1 -0
  25. package/lib/lsp.d.ts +129 -0
  26. package/lib/lsp.js +125 -0
  27. package/lib/lsp.js.map +1 -0
  28. package/lib/manager.d.ts +29 -0
  29. package/lib/manager.js +130 -0
  30. package/lib/manager.js.map +1 -0
  31. package/lib/plugin.d.ts +45 -0
  32. package/lib/plugin.js +3 -0
  33. package/lib/plugin.js.map +1 -0
  34. package/lib/positioning.d.ts +28 -0
  35. package/lib/positioning.js +49 -0
  36. package/lib/positioning.js.map +1 -0
  37. package/lib/schema.d.ts +228 -0
  38. package/lib/schema.js +3 -0
  39. package/lib/schema.js.map +1 -0
  40. package/lib/tokens.d.ts +368 -0
  41. package/lib/tokens.js +58 -0
  42. package/lib/tokens.js.map +1 -0
  43. package/lib/utils.d.ts +18 -0
  44. package/lib/utils.js +71 -0
  45. package/lib/utils.js.map +1 -0
  46. package/lib/virtual/document.d.ts +270 -0
  47. package/lib/virtual/document.js +600 -0
  48. package/lib/virtual/document.js.map +1 -0
  49. package/package.json +75 -0
  50. package/style/index.css +11 -0
  51. package/style/index.js +11 -0
@@ -0,0 +1,228 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run jlpm build:schema to regenerate this file.
5
+ */
6
+ /**
7
+ * which version of the spec this implements
8
+ *
9
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
10
+ * via the `definition` "current-version".
11
+ */
12
+ export declare type SpecSchemaVersion = 2;
13
+ /**
14
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
15
+ * via the `definition` "env-var".
16
+ *
17
+ * This interface was referenced by `EnvironmentVariables`'s JSON-Schema definition
18
+ * via the `patternProperty` "[^ ]+".
19
+ */
20
+ export declare type AnEnvironmentVariableMayContainPythonStringTemplateEvaluatedAgainstTheExistingEnvironmentEG$HOME = string;
21
+ /**
22
+ * the install commands or description for installing the language server
23
+ *
24
+ * This interface was referenced by `Installation`'s JSON-Schema definition
25
+ * via the `patternProperty` ".+".
26
+ *
27
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
28
+ * via the `definition` "install-help".
29
+ *
30
+ * This interface was referenced by `Installation1`'s JSON-Schema definition
31
+ * via the `patternProperty` ".+".
32
+ */
33
+ export declare type InstallHelp = string;
34
+ /**
35
+ * languages supported by this Language Server
36
+ *
37
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
38
+ * via the `definition` "language-list".
39
+ */
40
+ export declare type LanguageList = [string, ...string[]];
41
+ /**
42
+ * a description of a language server that could be started
43
+ *
44
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
45
+ * via the `definition` "language-server-spec".
46
+ *
47
+ * This interface was referenced by `LanguageServerSpecsMap`'s JSON-Schema definition
48
+ * via the `patternProperty` ".*".
49
+ */
50
+ export declare type LanguageServerSpec = ServerSpecProperties & {
51
+ [k: string]: any;
52
+ };
53
+ /**
54
+ * the arguments to start the language server normally
55
+ */
56
+ export declare type LaunchArguments = string[];
57
+ /**
58
+ * the arguments to start the language server with more verbose output
59
+ */
60
+ export declare type DebugArguments = string[];
61
+ /**
62
+ * name shown in the UI
63
+ */
64
+ export declare type DisplayName = string;
65
+ /**
66
+ * known extensions that can contribute to the Language Server's features
67
+ */
68
+ export declare type Extensions = LanguageServerExtension[];
69
+ /**
70
+ * list of MIME types supported by the language server
71
+ */
72
+ export declare type MIMETypes = [string, ...string[]];
73
+ /**
74
+ * information on troubleshooting the installation or auto-detection of the language server
75
+ */
76
+ export declare type Troubleshooting = string;
77
+ /**
78
+ * a date/time that might not have been recorded
79
+ *
80
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
81
+ * via the `definition` "nullable-date-time".
82
+ */
83
+ export declare type NullableDateTime = string | null;
84
+ /**
85
+ * the count of currently-connected WebSocket handlers
86
+ */
87
+ export declare type HandlerCount = number;
88
+ /**
89
+ * a list of tokens for running a command
90
+ *
91
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
92
+ * via the `definition` "shell-args".
93
+ */
94
+ export declare type ShellArgs = string[];
95
+ /**
96
+ * describes the current state of (potentially) running language servers
97
+ */
98
+ export interface JupyterLspServerStatusResponse {
99
+ [k: string]: any;
100
+ }
101
+ /**
102
+ * a JSON schema to configure the Language Server or extension behavior from the client
103
+ *
104
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
105
+ * via the `definition` "client-config-schema".
106
+ */
107
+ export interface ClientConfigurationSchema {
108
+ [k: string]: any;
109
+ }
110
+ /**
111
+ * a list of installation approaches keyed by package manager, e.g. pip, npm, yarn, apt
112
+ *
113
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
114
+ * via the `definition` "install-bundle".
115
+ */
116
+ export interface Installation {
117
+ [k: string]: InstallHelp;
118
+ }
119
+ /**
120
+ * an extension which can extend the functionality of the language server and client
121
+ *
122
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
123
+ * via the `definition` "language-server-extension".
124
+ */
125
+ export interface LanguageServerExtension {
126
+ config_schema?: ClientConfigurationSchema;
127
+ display_name?: string;
128
+ install?: Installation;
129
+ [k: string]: any;
130
+ }
131
+ /**
132
+ * all properties that might be required to start and/or describe a Language Server
133
+ *
134
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
135
+ * via the `definition` "partial-language-server-spec".
136
+ */
137
+ export interface ServerSpecProperties {
138
+ argv?: LaunchArguments;
139
+ config_schema?: ClientConfigurationSchema1;
140
+ debug_argv?: DebugArguments;
141
+ display_name?: DisplayName;
142
+ env?: EnvironmentVariables;
143
+ extend?: Extensions;
144
+ install?: Installation1;
145
+ languages?: LanguageList;
146
+ mime_types?: MIMETypes;
147
+ troubleshoot?: Troubleshooting;
148
+ urls?: URLs;
149
+ version?: SpecSchemaVersion;
150
+ [k: string]: any;
151
+ }
152
+ /**
153
+ * a JSON schema to configure the Language Server behavior from the client
154
+ */
155
+ export interface ClientConfigurationSchema1 {
156
+ [k: string]: any;
157
+ }
158
+ /**
159
+ * additional environment variables to set when starting the language server
160
+ */
161
+ export interface EnvironmentVariables {
162
+ [k: string]: AnEnvironmentVariableMayContainPythonStringTemplateEvaluatedAgainstTheExistingEnvironmentEG$HOME;
163
+ }
164
+ /**
165
+ * a list of installation approaches keyed by package manager, e.g. pip, npm, yarn, apt
166
+ */
167
+ export interface Installation1 {
168
+ [k: string]: InstallHelp;
169
+ }
170
+ /**
171
+ * a collection of urls keyed by type, e.g. home, issues
172
+ */
173
+ export interface URLs {
174
+ [k: string]: string;
175
+ }
176
+ /**
177
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
178
+ * via the `definition` "servers-response".
179
+ */
180
+ export interface ServersResponse {
181
+ sessions: Sessions;
182
+ specs?: LanguageServerSpecsMap;
183
+ version: SpecSchemaVersion;
184
+ [k: string]: any;
185
+ }
186
+ /**
187
+ * named server sessions that are, could be, or were running
188
+ *
189
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
190
+ * via the `definition` "sessions".
191
+ */
192
+ export interface Sessions {
193
+ [k: string]: LanguageServerSession;
194
+ }
195
+ /**
196
+ * a language server session
197
+ *
198
+ * This interface was referenced by `Sessions`'s JSON-Schema definition
199
+ * via the `patternProperty` ".*".
200
+ *
201
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
202
+ * via the `definition` "session".
203
+ */
204
+ export interface LanguageServerSession {
205
+ handler_count: HandlerCount;
206
+ /**
207
+ * date-time of last seen message from a WebSocket handler
208
+ */
209
+ last_handler_message_at: string | null;
210
+ /**
211
+ * date-time of last seen message from the language server
212
+ */
213
+ last_server_message_at: string | null;
214
+ spec: ServerSpecProperties;
215
+ /**
216
+ * a string describing the current state of the server
217
+ */
218
+ status: 'not_started' | 'starting' | 'started' | 'stopping' | 'stopped';
219
+ }
220
+ /**
221
+ * a set of language servers keyed by their implementation name
222
+ *
223
+ * This interface was referenced by `JupyterLspServerStatusResponse`'s JSON-Schema
224
+ * via the `definition` "language-server-specs-implementation-map".
225
+ */
226
+ export interface LanguageServerSpecsMap {
227
+ [k: string]: LanguageServerSpec;
228
+ }
package/lib/schema.js ADDED
@@ -0,0 +1,3 @@
1
+ /* eslint-disable */
2
+ export {};
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,oBAAoB"}
@@ -0,0 +1,368 @@
1
+ import { IDocumentWidget } from '@jupyterlab/docregistry';
2
+ import { CellType } from '@jupyterlab/nbformat';
3
+ import { ServerConnection } from '@jupyterlab/services';
4
+ import { Token } from '@lumino/coreutils';
5
+ import { ISignal, Signal } from '@lumino/signaling';
6
+ import { AnyCompletion, AnyLocation, IDocumentInfo, ILspConnection, ILspOptions, IPosition, ITokenInfo } from 'lsp-ws-connection';
7
+ import { WidgetAdapter } from './adapters/adapter';
8
+ import { IForeignCodeExtractor } from './extractors/types';
9
+ import { ClientCapabilities, LanguageIdentifier } from './lsp';
10
+ import { LanguageServer2 as LSPLanguageServerSettings } from './plugin';
11
+ import * as SCHEMA from './schema';
12
+ import { VirtualDocument } from './virtual/document';
13
+ import type * as rpc from 'vscode-jsonrpc';
14
+ import type * as lsp from 'vscode-languageserver-protocol';
15
+ export declare type TLanguageServerId = 'pylsp' | 'bash-language-server' | 'dockerfile-language-server-nodejs' | 'javascript-typescript-langserver' | 'unified-language-server' | 'vscode-css-languageserver-bin' | 'vscode-html-languageserver-bin' | 'vscode-json-languageserver-bin' | 'yaml-language-server' | 'r-languageserver';
16
+ export declare type TServerKeys = TLanguageServerId;
17
+ export declare type TLanguageServerConfigurations = Partial<Record<TServerKeys, LSPLanguageServerSettings>>;
18
+ export declare type TSessionMap = Map<TServerKeys, SCHEMA.LanguageServerSession>;
19
+ export declare type TSpecsMap = Map<TServerKeys, SCHEMA.LanguageServerSpec>;
20
+ export declare type TLanguageId = string;
21
+ export interface ILanguageServerManager {
22
+ /**
23
+ * Signal emitted when the language server sessions are changed.
24
+ *
25
+ */
26
+ sessionsChanged: ISignal<ILanguageServerManager, void>;
27
+ /**
28
+ * The current session information of running language servers.
29
+ */
30
+ sessions: TSessionMap;
31
+ /**
32
+ * An ordered list of matching >running< sessions, with servers of higher priority higher in the list
33
+ */
34
+ getMatchingServers(options: ILanguageServerManager.IGetServerIdOptions): TLanguageServerId[];
35
+ /**
36
+ * A list of all known matching specs (whether detected or not).
37
+ */
38
+ getMatchingSpecs(options: ILanguageServerManager.IGetServerIdOptions): TSpecsMap;
39
+ /**
40
+ * Set the configuration for language servers
41
+ *
42
+ */
43
+ setConfiguration(configuration: TLanguageServerConfigurations): void;
44
+ /**
45
+ * Send a request to language server handler to get the session information.
46
+ *
47
+ */
48
+ fetchSessions(): Promise<void>;
49
+ /**
50
+ * Current endpoint to get the status of running language servers
51
+ */
52
+ statusUrl: string;
53
+ /**
54
+ *
55
+ * Status code of the `fetchSession` request.
56
+ */
57
+ statusCode: number;
58
+ }
59
+ export declare namespace ILanguageServerManager {
60
+ const URL_NS = "lsp";
61
+ interface IOptions {
62
+ settings?: ServerConnection.ISettings;
63
+ baseUrl?: string;
64
+ /**
65
+ * Number of connection retries to fetch the sessions.
66
+ * Default 2.
67
+ */
68
+ retries?: number;
69
+ /**
70
+ * The interval for retries, default 10 seconds.
71
+ */
72
+ retriesInterval?: number;
73
+ }
74
+ interface IGetServerIdOptions {
75
+ language?: TLanguageId;
76
+ mimeType?: string;
77
+ }
78
+ }
79
+ export interface ISocketConnectionOptions {
80
+ virtualDocument: VirtualDocument;
81
+ /**
82
+ * The language identifier, corresponding to the API endpoint on the LSP proxy server.
83
+ */
84
+ language: string;
85
+ /**
86
+ * LSP capabilities describing currently supported features
87
+ */
88
+ capabilities: ClientCapabilities;
89
+ hasLspSupportedFile: boolean;
90
+ }
91
+ export interface IDocumentRegistationOptions {
92
+ /**
93
+ * The language identifier, corresponding to the API endpoint on the LSP proxy server.
94
+ */
95
+ language: string;
96
+ /**
97
+ * Path to the document in the JupyterLab space
98
+ */
99
+ document: string;
100
+ /**
101
+ * LSP capabilities describing currently supported features
102
+ */
103
+ capabilities: ClientCapabilities;
104
+ hasLspSupportedFile: boolean;
105
+ }
106
+ export interface IDocumentConnectionData {
107
+ virtualDocument: VirtualDocument;
108
+ connection: ILSPConnection;
109
+ }
110
+ export interface ILSPDocumentConnectionManager {
111
+ /**
112
+ * The mapping of document uri to the connection to language server.
113
+ */
114
+ connections: Map<VirtualDocument.uri, ILSPConnection>;
115
+ /**
116
+ * The mapping of document uri to the virtual document.
117
+ */
118
+ documents: Map<VirtualDocument.uri, VirtualDocument>;
119
+ /**
120
+ * The mapping of document uri to the widget adapter.
121
+ */
122
+ adapters: Map<string, WidgetAdapter<IDocumentWidget>>;
123
+ /**
124
+ * Signal emitted when a connection is connected.
125
+ */
126
+ connected: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
127
+ /**
128
+ * Signal emitted when a connection is disconnected.
129
+ */
130
+ disconnected: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
131
+ /**
132
+ * Signal emitted when the language server is initialized.
133
+ */
134
+ initialized: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
135
+ /**
136
+ * Signal emitted when a virtual document is closed.
137
+ */
138
+ closed: ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData>;
139
+ /**
140
+ * Signal emitted when the content of a virtual document is changed.
141
+ */
142
+ documentsChanged: ISignal<ILSPDocumentConnectionManager, Map<VirtualDocument.uri, VirtualDocument>>;
143
+ /**
144
+ * The language server manager instance.
145
+ */
146
+ languageServerManager: ILanguageServerManager;
147
+ /**
148
+ * Handles the settings that do not require an existing connection
149
+ * with a language server (or can influence to which server the
150
+ * connection will be created, e.g. `priority`).
151
+ *
152
+ * This function should be called **before** initialization of servers.
153
+ */
154
+ updateConfiguration(allServerSettings: TLanguageServerConfigurations): void;
155
+ /**
156
+ * Handles the settings that the language servers accept using
157
+ * `onDidChangeConfiguration` messages, which should be passed under
158
+ * the "serverSettings" keyword in the setting registry.
159
+ * Other configuration options are handled by `updateConfiguration` instead.
160
+ *
161
+ * This function should be called **after** initialization of servers.
162
+ */
163
+ updateServerConfigurations(allServerSettings: TLanguageServerConfigurations): void;
164
+ /**
165
+ * Retry to connect to the server each `reconnectDelay` seconds
166
+ * and for `retrialsLeft` times.
167
+ *
168
+ */
169
+ retryToConnect(options: ISocketConnectionOptions, reconnectDelay: number, retrialsLeft: number): Promise<void>;
170
+ /**
171
+ * Create a new connection to the language server
172
+ * @return A promise of the LSP connection
173
+ */
174
+ connect(options: ISocketConnectionOptions, firstTimeoutSeconds?: number, secondTimeoutMinute?: number): Promise<ILSPConnection | undefined>;
175
+ /**
176
+ * Disconnect the connection to the language server of the requested
177
+ * language.
178
+ *
179
+ */
180
+ disconnect(languageId: TLanguageServerId): void;
181
+ /**
182
+ * Disconnect the signals of requested virtual document.
183
+ *
184
+ */
185
+ unregisterDocument(virtualDocument: VirtualDocument): void;
186
+ /**
187
+ * Register a widget adapter.
188
+ *
189
+ * @param path - path to current document widget of input adapter
190
+ * @param adapter - the adapter need to be registered
191
+ */
192
+ registerAdapter(path: string, adapter: WidgetAdapter<IDocumentWidget>): void;
193
+ }
194
+ export interface IFeature {
195
+ /**
196
+ * The feature identifier. It must be the same as the feature plugin id.
197
+ */
198
+ id: string;
199
+ /**
200
+ * LSP capabilities implemented by the feature.
201
+ */
202
+ capabilities?: ClientCapabilities;
203
+ }
204
+ export interface ILSPFeatureManager {
205
+ /**
206
+ * A read-only registry of all registered features.
207
+ */
208
+ readonly features: IFeature[];
209
+ /**
210
+ * Register the new feature (frontend capability)
211
+ * for one or more code editor implementations.
212
+ */
213
+ register(feature: IFeature): void;
214
+ featuresRegistered: ISignal<ILSPFeatureManager, IFeature>;
215
+ clientCapabilities(): ClientCapabilities;
216
+ }
217
+ /**
218
+ * Manages code transclusion plugins.
219
+ */
220
+ export interface ILSPCodeExtractorsManager {
221
+ /**
222
+ * Get the foreign code extractors.
223
+ */
224
+ getExtractors(cellType: CellType, hostLanguage: string | null): IForeignCodeExtractor[];
225
+ /**
226
+ * Register the extraction rules to be applied in documents with language `host_language`.
227
+ */
228
+ register(extractor: IForeignCodeExtractor, hostLanguage: LanguageIdentifier | null): void;
229
+ }
230
+ export declare const ILSPDocumentConnectionManager: Token<ILSPDocumentConnectionManager>;
231
+ export declare const ILSPFeatureManager: Token<ILSPFeatureManager>;
232
+ export declare const ILSPCodeExtractorsManager: Token<ILSPCodeExtractorsManager>;
233
+ export interface ILSPOptions extends ILspOptions {
234
+ capabilities: ClientCapabilities;
235
+ serverIdentifier?: string;
236
+ }
237
+ /**
238
+ * Method strings are reproduced here because a non-typing import of
239
+ * `vscode-languageserver-protocol` is ridiculously expensive.
240
+ */
241
+ export declare namespace Method {
242
+ /** Server notifications */
243
+ enum ServerNotification {
244
+ PUBLISH_DIAGNOSTICS = "textDocument/publishDiagnostics",
245
+ SHOW_MESSAGE = "window/showMessage",
246
+ LOG_TRACE = "$/logTrace",
247
+ LOG_MESSAGE = "window/logMessage"
248
+ }
249
+ /** Client notifications */
250
+ enum ClientNotification {
251
+ DID_CHANGE = "textDocument/didChange",
252
+ DID_CHANGE_CONFIGURATION = "workspace/didChangeConfiguration",
253
+ DID_OPEN = "textDocument/didOpen",
254
+ DID_SAVE = "textDocument/didSave",
255
+ INITIALIZED = "initialized",
256
+ SET_TRACE = "$/setTrace"
257
+ }
258
+ /** Server requests */
259
+ enum ServerRequest {
260
+ REGISTER_CAPABILITY = "client/registerCapability",
261
+ SHOW_MESSAGE_REQUEST = "window/showMessageRequest",
262
+ UNREGISTER_CAPABILITY = "client/unregisterCapability",
263
+ WORKSPACE_CONFIGURATION = "workspace/configuration"
264
+ }
265
+ /** Client requests */
266
+ enum ClientRequest {
267
+ COMPLETION = "textDocument/completion",
268
+ COMPLETION_ITEM_RESOLVE = "completionItem/resolve",
269
+ DEFINITION = "textDocument/definition",
270
+ DOCUMENT_HIGHLIGHT = "textDocument/documentHighlight",
271
+ DOCUMENT_SYMBOL = "textDocument/documentSymbol",
272
+ HOVER = "textDocument/hover",
273
+ IMPLEMENTATION = "textDocument/implementation",
274
+ INITIALIZE = "initialize",
275
+ REFERENCES = "textDocument/references",
276
+ RENAME = "textDocument/rename",
277
+ SIGNATURE_HELP = "textDocument/signatureHelp",
278
+ TYPE_DEFINITION = "textDocument/typeDefinition"
279
+ }
280
+ }
281
+ export interface IServerNotifyParams {
282
+ [Method.ServerNotification.LOG_MESSAGE]: lsp.LogMessageParams;
283
+ [Method.ServerNotification.LOG_TRACE]: rpc.LogTraceParams;
284
+ [Method.ServerNotification.PUBLISH_DIAGNOSTICS]: lsp.PublishDiagnosticsParams;
285
+ [Method.ServerNotification.SHOW_MESSAGE]: lsp.ShowMessageParams;
286
+ }
287
+ export interface IClientNotifyParams {
288
+ [Method.ClientNotification
289
+ .DID_CHANGE_CONFIGURATION]: lsp.DidChangeConfigurationParams;
290
+ [Method.ClientNotification.DID_CHANGE]: lsp.DidChangeTextDocumentParams;
291
+ [Method.ClientNotification.DID_OPEN]: lsp.DidOpenTextDocumentParams;
292
+ [Method.ClientNotification.DID_SAVE]: lsp.DidSaveTextDocumentParams;
293
+ [Method.ClientNotification.INITIALIZED]: lsp.InitializedParams;
294
+ [Method.ClientNotification.SET_TRACE]: rpc.SetTraceParams;
295
+ }
296
+ export interface IServerRequestParams {
297
+ [Method.ServerRequest.REGISTER_CAPABILITY]: lsp.RegistrationParams;
298
+ [Method.ServerRequest.SHOW_MESSAGE_REQUEST]: lsp.ShowMessageRequestParams;
299
+ [Method.ServerRequest.UNREGISTER_CAPABILITY]: lsp.UnregistrationParams;
300
+ [Method.ServerRequest.WORKSPACE_CONFIGURATION]: lsp.ConfigurationParams;
301
+ }
302
+ export interface IServerResult {
303
+ [Method.ServerRequest.REGISTER_CAPABILITY]: void;
304
+ [Method.ServerRequest.SHOW_MESSAGE_REQUEST]: lsp.MessageActionItem | null;
305
+ [Method.ServerRequest.UNREGISTER_CAPABILITY]: void;
306
+ [Method.ServerRequest.WORKSPACE_CONFIGURATION]: any[];
307
+ }
308
+ export interface IClientRequestParams {
309
+ [Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
310
+ [Method.ClientRequest.COMPLETION]: lsp.CompletionParams;
311
+ [Method.ClientRequest.DEFINITION]: lsp.TextDocumentPositionParams;
312
+ [Method.ClientRequest.DOCUMENT_HIGHLIGHT]: lsp.TextDocumentPositionParams;
313
+ [Method.ClientRequest.DOCUMENT_SYMBOL]: lsp.DocumentSymbolParams;
314
+ [Method.ClientRequest.HOVER]: lsp.TextDocumentPositionParams;
315
+ [Method.ClientRequest.IMPLEMENTATION]: lsp.TextDocumentPositionParams;
316
+ [Method.ClientRequest.INITIALIZE]: lsp.InitializeParams;
317
+ [Method.ClientRequest.REFERENCES]: lsp.ReferenceParams;
318
+ [Method.ClientRequest.RENAME]: lsp.RenameParams;
319
+ [Method.ClientRequest.SIGNATURE_HELP]: lsp.TextDocumentPositionParams;
320
+ [Method.ClientRequest.TYPE_DEFINITION]: lsp.TextDocumentPositionParams;
321
+ }
322
+ export interface IClientResult {
323
+ [Method.ClientRequest.COMPLETION_ITEM_RESOLVE]: lsp.CompletionItem;
324
+ [Method.ClientRequest.COMPLETION]: AnyCompletion;
325
+ [Method.ClientRequest.DEFINITION]: AnyLocation;
326
+ [Method.ClientRequest.DOCUMENT_HIGHLIGHT]: lsp.DocumentHighlight[];
327
+ [Method.ClientRequest.DOCUMENT_SYMBOL]: lsp.DocumentSymbol[];
328
+ [Method.ClientRequest.HOVER]: lsp.Hover | null;
329
+ [Method.ClientRequest.IMPLEMENTATION]: AnyLocation;
330
+ [Method.ClientRequest.INITIALIZE]: lsp.InitializeResult;
331
+ [Method.ClientRequest.REFERENCES]: lsp.Location[] | null;
332
+ [Method.ClientRequest.RENAME]: lsp.WorkspaceEdit;
333
+ [Method.ClientRequest.SIGNATURE_HELP]: lsp.SignatureHelp;
334
+ [Method.ClientRequest.TYPE_DEFINITION]: AnyLocation;
335
+ }
336
+ export declare type ServerNotifications<T extends keyof IServerNotifyParams = keyof IServerNotifyParams> = {
337
+ readonly [key in T]: ISignal<ILSPConnection, IServerNotifyParams[key]>;
338
+ };
339
+ export declare type ClientNotifications<T extends keyof IClientNotifyParams = keyof IClientNotifyParams> = {
340
+ readonly [key in T]: Signal<ILSPConnection, IClientNotifyParams[key]>;
341
+ };
342
+ export interface IClientRequestHandler<T extends keyof IClientRequestParams = keyof IClientRequestParams> {
343
+ request(params: IClientRequestParams[T]): Promise<IClientResult[T]>;
344
+ }
345
+ export interface IServerRequestHandler<T extends keyof IServerRequestParams = keyof IServerRequestParams> {
346
+ setHandler(handler: (params: IServerRequestParams[T], connection?: ILSPConnection) => Promise<IServerResult[T]>): void;
347
+ clearHandler(): void;
348
+ }
349
+ export declare type ClientRequests<T extends keyof IClientRequestParams = keyof IClientRequestParams> = {
350
+ readonly [key in T]: IClientRequestHandler<key>;
351
+ };
352
+ export declare type ServerRequests<T extends keyof IServerRequestParams = keyof IServerRequestParams> = {
353
+ readonly [key in T]: IServerRequestHandler<key>;
354
+ };
355
+ export interface ILSPConnection extends ILspConnection {
356
+ serverIdentifier?: string;
357
+ serverLanguage?: string;
358
+ logAllCommunication: boolean;
359
+ isReady: boolean;
360
+ clientNotifications: ClientNotifications;
361
+ serverNotifications: ServerNotifications;
362
+ clientRequests: ClientRequests;
363
+ serverRequests: ServerRequests;
364
+ sendSaved(documentInfo: IDocumentInfo): void;
365
+ sendOpenWhenReady(documentInfo: IDocumentInfo): void;
366
+ sendFullTextChange(text: string, documentInfo: IDocumentInfo): void;
367
+ getCompletion(location: IPosition, token: ITokenInfo, documentInfo: IDocumentInfo, emit?: boolean, triggerCharacter?: string, triggerKind?: lsp.CompletionTriggerKind): Promise<lsp.CompletionItem[] | undefined>;
368
+ }
package/lib/tokens.js ADDED
@@ -0,0 +1,58 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ export var ILanguageServerManager;
3
+ (function (ILanguageServerManager) {
4
+ ILanguageServerManager.URL_NS = 'lsp';
5
+ })(ILanguageServerManager || (ILanguageServerManager = {}));
6
+ export const ILSPDocumentConnectionManager = new Token('@jupyterlab/lsp:ILSPDocumentConnectionManager');
7
+ export const ILSPFeatureManager = new Token('@jupyterlab/lsp:ILSPFeatureManager');
8
+ export const ILSPCodeExtractorsManager = new Token('@jupyterlab/lsp:ILSPCodeExtractorsManager');
9
+ /**
10
+ * Method strings are reproduced here because a non-typing import of
11
+ * `vscode-languageserver-protocol` is ridiculously expensive.
12
+ */
13
+ export var Method;
14
+ (function (Method) {
15
+ /** Server notifications */
16
+ let ServerNotification;
17
+ (function (ServerNotification) {
18
+ ServerNotification["PUBLISH_DIAGNOSTICS"] = "textDocument/publishDiagnostics";
19
+ ServerNotification["SHOW_MESSAGE"] = "window/showMessage";
20
+ ServerNotification["LOG_TRACE"] = "$/logTrace";
21
+ ServerNotification["LOG_MESSAGE"] = "window/logMessage";
22
+ })(ServerNotification = Method.ServerNotification || (Method.ServerNotification = {}));
23
+ /** Client notifications */
24
+ let ClientNotification;
25
+ (function (ClientNotification) {
26
+ ClientNotification["DID_CHANGE"] = "textDocument/didChange";
27
+ ClientNotification["DID_CHANGE_CONFIGURATION"] = "workspace/didChangeConfiguration";
28
+ ClientNotification["DID_OPEN"] = "textDocument/didOpen";
29
+ ClientNotification["DID_SAVE"] = "textDocument/didSave";
30
+ ClientNotification["INITIALIZED"] = "initialized";
31
+ ClientNotification["SET_TRACE"] = "$/setTrace";
32
+ })(ClientNotification = Method.ClientNotification || (Method.ClientNotification = {}));
33
+ /** Server requests */
34
+ let ServerRequest;
35
+ (function (ServerRequest) {
36
+ ServerRequest["REGISTER_CAPABILITY"] = "client/registerCapability";
37
+ ServerRequest["SHOW_MESSAGE_REQUEST"] = "window/showMessageRequest";
38
+ ServerRequest["UNREGISTER_CAPABILITY"] = "client/unregisterCapability";
39
+ ServerRequest["WORKSPACE_CONFIGURATION"] = "workspace/configuration";
40
+ })(ServerRequest = Method.ServerRequest || (Method.ServerRequest = {}));
41
+ /** Client requests */
42
+ let ClientRequest;
43
+ (function (ClientRequest) {
44
+ ClientRequest["COMPLETION"] = "textDocument/completion";
45
+ ClientRequest["COMPLETION_ITEM_RESOLVE"] = "completionItem/resolve";
46
+ ClientRequest["DEFINITION"] = "textDocument/definition";
47
+ ClientRequest["DOCUMENT_HIGHLIGHT"] = "textDocument/documentHighlight";
48
+ ClientRequest["DOCUMENT_SYMBOL"] = "textDocument/documentSymbol";
49
+ ClientRequest["HOVER"] = "textDocument/hover";
50
+ ClientRequest["IMPLEMENTATION"] = "textDocument/implementation";
51
+ ClientRequest["INITIALIZE"] = "initialize";
52
+ ClientRequest["REFERENCES"] = "textDocument/references";
53
+ ClientRequest["RENAME"] = "textDocument/rename";
54
+ ClientRequest["SIGNATURE_HELP"] = "textDocument/signatureHelp";
55
+ ClientRequest["TYPE_DEFINITION"] = "textDocument/typeDefinition";
56
+ })(ClientRequest = Method.ClientRequest || (Method.ClientRequest = {}));
57
+ })(Method || (Method = {}));
58
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA8F1C,MAAM,KAAW,sBAAsB,CAmBtC;AAnBD,WAAiB,sBAAsB;IACxB,6BAAM,GAAG,KAAK,CAAC;AAkB9B,CAAC,EAnBgB,sBAAsB,KAAtB,sBAAsB,QAmBtC;AAyMD,MAAM,CAAC,MAAM,6BAA6B,GACxC,IAAI,KAAK,CACP,+CAA+C,CAChD,CAAC;AAEJ,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,KAAK,CACzC,oCAAoC,CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,KAAK,CAChD,2CAA2C,CAC5C,CAAC;AAOF;;;GAGG;AACH,MAAM,KAAW,MAAM,CA0CtB;AA1CD,WAAiB,MAAM;IACrB,2BAA2B;IAC3B,IAAY,kBAKX;IALD,WAAY,kBAAkB;QAC5B,6EAAuD,CAAA;QACvD,yDAAmC,CAAA;QACnC,8CAAwB,CAAA;QACxB,uDAAiC,CAAA;IACnC,CAAC,EALW,kBAAkB,GAAlB,yBAAkB,KAAlB,yBAAkB,QAK7B;IAED,2BAA2B;IAC3B,IAAY,kBAOX;IAPD,WAAY,kBAAkB;QAC5B,2DAAqC,CAAA;QACrC,mFAA6D,CAAA;QAC7D,uDAAiC,CAAA;QACjC,uDAAiC,CAAA;QACjC,iDAA2B,CAAA;QAC3B,8CAAwB,CAAA;IAC1B,CAAC,EAPW,kBAAkB,GAAlB,yBAAkB,KAAlB,yBAAkB,QAO7B;IAED,sBAAsB;IACtB,IAAY,aAKX;IALD,WAAY,aAAa;QACvB,kEAAiD,CAAA;QACjD,mEAAkD,CAAA;QAClD,sEAAqD,CAAA;QACrD,oEAAmD,CAAA;IACrD,CAAC,EALW,aAAa,GAAb,oBAAa,KAAb,oBAAa,QAKxB;IAED,sBAAsB;IACtB,IAAY,aAaX;IAbD,WAAY,aAAa;QACvB,uDAAsC,CAAA;QACtC,mEAAkD,CAAA;QAClD,uDAAsC,CAAA;QACtC,sEAAqD,CAAA;QACrD,gEAA+C,CAAA;QAC/C,6CAA4B,CAAA;QAC5B,+DAA8C,CAAA;QAC9C,0CAAyB,CAAA;QACzB,uDAAsC,CAAA;QACtC,+CAA8B,CAAA;QAC9B,8DAA6C,CAAA;QAC7C,gEAA+C,CAAA;IACjD,CAAC,EAbW,aAAa,GAAb,oBAAa,KAAb,oBAAa,QAaxB;AACH,CAAC,EA1CgB,MAAM,KAAN,MAAM,QA0CtB"}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { ReadonlyJSONObject, ReadonlyJSONValue } from '@lumino/coreutils';
2
+ export declare function sleep(timeout: number): Promise<void>;
3
+ export declare function untilReady(isReady: CallableFunction, maxRetrials?: number, interval?: number, intervalModifier?: (i: number) => number): Promise<CallableFunction>;
4
+ export declare const expandDottedPaths: (obj: ReadonlyJSONObject) => ReadonlyJSONObject;
5
+ /**
6
+ * The docs for many language servers show settings in the
7
+ * VSCode format, e.g.: "pyls.plugins.pyflakes.enabled"
8
+ *
9
+ * VSCode converts that dot notation to JSON behind the scenes,
10
+ * as the language servers themselves don't accept that syntax.
11
+ */
12
+ export declare const expandPath: (path: string[], value: ReadonlyJSONValue) => ReadonlyJSONObject;
13
+ export declare class DefaultMap<K, V> extends Map<K, V> {
14
+ private defaultFactory;
15
+ constructor(defaultFactory: (...args: any[]) => V, entries?: ReadonlyArray<readonly [K, V]> | null);
16
+ get(k: K): V;
17
+ getOrCreate(k: K, ...args: any[]): V;
18
+ }