codemirror-languageserver 1.15.0 → 1.17.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/dist/plugin.d.ts CHANGED
@@ -16,6 +16,15 @@ interface LSPRequestMap {
16
16
  LSP.DefinitionParams,
17
17
  LSP.Location | LSP.Location[] | LSP.LocationLink[] | null
18
18
  ];
19
+ 'textDocument/declaration': [
20
+ LSP.DeclarationParams,
21
+ LSP.Location | LSP.Location[] | LSP.LocationLink[] | null
22
+ ];
23
+ 'textDocument/typeDefinition': [
24
+ LSP.TypeDefinitionParams,
25
+ LSP.Location | LSP.Location[] | LSP.LocationLink[] | null
26
+ ];
27
+ 'completionItem/resolve': [LSP.CompletionItem, LSP.CompletionItem];
19
28
  }
20
29
  interface LSPNotifyMap {
21
30
  initialized: LSP.InitializedParams;
@@ -33,6 +42,11 @@ type Notification = {
33
42
  params: LSPEventMap[key];
34
43
  };
35
44
  }[keyof LSPEventMap];
45
+ interface LanguageServerClientLocationMethods {
46
+ textDocumentDefinition(params: LSP.DefinitionParams): LSP.Location | LSP.Location[] | LSP.LocationLink[] | null;
47
+ textDocumentDeclaration(params: LSP.DeclarationParams): LSP.Location | LSP.Location[] | LSP.LocationLink[] | null;
48
+ textDocumentTypeDefinition(params: LSP.TypeDefinitionParams): LSP.Location | LSP.Location[] | LSP.LocationLink[] | null;
49
+ }
36
50
  export declare class LanguageServerClient<InitializationOptions = unknown> {
37
51
  ready: boolean;
38
52
  capabilities: LSP.ServerCapabilities<any>;
@@ -54,21 +68,29 @@ export declare class LanguageServerClient<InitializationOptions = unknown> {
54
68
  textDocumentHover(params: LSP.HoverParams): Promise<LSP.Hover>;
55
69
  textDocumentCompletion(params: LSP.CompletionParams): Promise<LSP.CompletionList | LSP.CompletionItem[]>;
56
70
  textDocumentDefinition(params: LSP.DefinitionParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
71
+ textDocumentDeclaration(params: LSP.DeclarationParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
72
+ textDocumentTypeDefinition(params: LSP.TypeDefinitionParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
73
+ completionItemResolve(params: LSP.CompletionItem): Promise<LSP.CompletionItem>;
57
74
  attachPlugin(plugin: LanguageServerPlugin): void;
58
75
  detachPlugin(plugin: LanguageServerPlugin): void;
59
76
  protected request<K extends keyof LSPRequestMap>(method: K, params: LSPRequestMap[K][0], timeout: number): Promise<LSPRequestMap[K][1]>;
60
77
  protected notify<K extends keyof LSPNotifyMap>(method: K, params: LSPNotifyMap[K]): Promise<LSPNotifyMap[K]>;
61
78
  protected processNotification(notification: Notification): void;
62
79
  }
63
- declare class LanguageServerPlugin implements PluginValue {
80
+ export declare class LanguageServerPlugin implements PluginValue {
64
81
  private view;
65
- private allowHTMLContent;
66
82
  client: LanguageServerClient;
67
83
  private documentUri;
68
84
  private languageId;
69
85
  private documentVersion;
86
+ private allowHTMLContent;
70
87
  private changesTimeout;
71
- constructor(view: EditorView, allowHTMLContent: boolean);
88
+ constructor(view: EditorView, { client, documentUri, languageId, allowHTMLContent, }: {
89
+ client: LanguageServerClient;
90
+ documentUri: string;
91
+ languageId: string;
92
+ allowHTMLContent: boolean;
93
+ });
72
94
  update({ docChanged }: ViewUpdate): void;
73
95
  destroy(): void;
74
96
  initialize({ documentText }: {
@@ -89,6 +111,13 @@ declare class LanguageServerPlugin implements PluginValue {
89
111
  triggerKind: CompletionTriggerKind;
90
112
  triggerCharacter: string | undefined;
91
113
  }): Promise<CompletionResult | null>;
114
+ requestLocation(view: EditorView, { line, character }: {
115
+ line: number;
116
+ character: number;
117
+ }, capability: keyof LSP.ServerCapabilities<any>, method: keyof LanguageServerClientLocationMethods): Promise<{
118
+ uri: string;
119
+ range: LSP.Range;
120
+ }>;
92
121
  requestDefinition(view: EditorView, { line, character }: {
93
122
  line: number;
94
123
  character: number;
@@ -96,312 +125,38 @@ declare class LanguageServerPlugin implements PluginValue {
96
125
  uri: string;
97
126
  range: LSP.Range;
98
127
  }>;
128
+ requestDeclaration(view: EditorView, { line, character }: {
129
+ line: number;
130
+ character: number;
131
+ }): Promise<{
132
+ uri: string;
133
+ range: LSP.Range;
134
+ }>;
135
+ requestTypeDefinition(view: EditorView, { line, character }: {
136
+ line: number;
137
+ character: number;
138
+ }): Promise<{
139
+ uri: string;
140
+ range: LSP.Range;
141
+ }>;
99
142
  processNotification(notification: Notification): void;
100
143
  processDiagnostics(params: PublishDiagnosticsParams): void;
101
144
  }
102
- export declare const languageServerPlugin: ViewPlugin<LanguageServerPlugin, boolean>;
103
- interface LanguageServerBaseOptions {
145
+ export declare const languageServerPlugin: ViewPlugin<LanguageServerPlugin, {
146
+ client: LanguageServerClient;
147
+ documentUri: string;
148
+ languageId: string;
149
+ allowHTMLContent: boolean;
150
+ }>;
151
+ export interface LanguageServerBaseOptions {
104
152
  rootUri: string | null;
105
153
  workspaceFolders: LSP.WorkspaceFolder[] | null;
106
154
  documentUri: string;
107
155
  languageId: string;
108
156
  }
109
- interface LanguageServerClientOptions<InitializationOptions = unknown> extends LanguageServerBaseOptions {
157
+ export interface LanguageServerClientOptions<InitializationOptions = unknown> extends LanguageServerBaseOptions {
110
158
  transport: Transport;
111
159
  autoClose?: boolean;
112
160
  initializationOptions?: InitializationOptions;
113
161
  }
114
- interface LanguageServerOptions<InitializationOptions = unknown> extends LanguageServerClientOptions<InitializationOptions> {
115
- client?: LanguageServerClient<InitializationOptions>;
116
- allowHTMLContent?: boolean;
117
- }
118
- interface LanguageServerWebsocketOptions<InitializationOptions = unknown> extends LanguageServerBaseOptions {
119
- serverUri: `ws://${string}` | `wss://${string}`;
120
- initializationOptions?: InitializationOptions;
121
- }
122
- export declare function languageServer<InitializationOptions = unknown>(options: LanguageServerWebsocketOptions<InitializationOptions>): ({
123
- extension: import("@codemirror/state").Extension;
124
- } | readonly import("@codemirror/state").Extension[])[];
125
- export declare function languageServerWithTransport<InitializationOptions = unknown>(options: LanguageServerOptions<InitializationOptions>): ({
126
- extension: import("@codemirror/state").Extension;
127
- } | readonly import("@codemirror/state").Extension[])[];
128
- /**
129
- * Initialization options for Pyright language server
130
- * @see https://github.com/microsoft/pyright/blob/main/docs/settings.md
131
- */
132
- export interface PyrightInitializationOptions {
133
- python?: {
134
- pythonPath?: string;
135
- venvPath?: string;
136
- analysis?: {
137
- autoSearchPaths?: boolean;
138
- extraPaths?: string[];
139
- diagnosticMode?: 'workspace' | 'openFilesOnly';
140
- stubPath?: string;
141
- typeshedPaths?: string[];
142
- useLibraryCodeForTypes?: boolean;
143
- typeCheckingMode?: 'off' | 'basic' | 'strict';
144
- autoImportCompletions?: boolean;
145
- indexing?: boolean;
146
- };
147
- };
148
- reportMissingImports?: boolean;
149
- reportMissingTypeStubs?: boolean;
150
- reportMissingModuleSource?: boolean;
151
- reportInvalidTypeVarUse?: boolean;
152
- reportOptionalSubscript?: boolean;
153
- reportOptionalMemberAccess?: boolean;
154
- reportOptionalCall?: boolean;
155
- reportOptionalIterable?: boolean;
156
- reportOptionalContextManager?: boolean;
157
- reportOptionalOperand?: boolean;
158
- reportTypedDictNotRequiredAccess?: boolean;
159
- reportPrivateImportUsage?: boolean;
160
- reportConstantRedefinition?: boolean;
161
- reportIncompatibleMethodOverride?: boolean;
162
- reportIncompatibleVariableOverride?: boolean;
163
- reportInconsistentConstructor?: boolean;
164
- }
165
- /**
166
- * Initialization options for Rust Analyzer language server
167
- * @see https://rust-analyzer.github.io/manual.html#configuration
168
- */
169
- export interface RustAnalyzerInitializationOptions {
170
- cargo?: {
171
- buildScripts?: {
172
- enable?: boolean;
173
- invocationStrategy?: 'per_workspace' | 'once';
174
- invocationLocation?: 'workspace' | 'root';
175
- };
176
- allTargets?: boolean;
177
- noDefaultFeatures?: boolean;
178
- allFeatures?: boolean;
179
- features?: string[];
180
- target?: string;
181
- runBuildScripts?: boolean;
182
- useRustcWrapperForBuildScripts?: boolean;
183
- };
184
- procMacro?: {
185
- enable?: boolean;
186
- ignored?: Record<string, string[]>;
187
- server?: string;
188
- attributes?: {
189
- enable?: boolean;
190
- };
191
- };
192
- diagnostics?: {
193
- enable?: boolean;
194
- disabled?: string[];
195
- warningsAsHint?: string[];
196
- warningsAsInfo?: string[];
197
- remapPrefix?: Record<string, string>;
198
- experimental?: {
199
- enable?: boolean;
200
- };
201
- };
202
- completion?: {
203
- addCallArgumentSnippets?: boolean;
204
- addCallParenthesis?: boolean;
205
- postfix?: {
206
- enable?: boolean;
207
- };
208
- autoimport?: {
209
- enable?: boolean;
210
- };
211
- privateEditable?: {
212
- enable?: boolean;
213
- };
214
- };
215
- assist?: {
216
- importGranularity?: 'preserve' | 'crate' | 'module' | 'item';
217
- importEnforceGranularity?: boolean;
218
- importPrefix?: 'plain' | 'by_self' | 'by_crate';
219
- allowMergingIntoGlobImports?: boolean;
220
- };
221
- callInfo?: {
222
- full?: boolean;
223
- };
224
- lens?: {
225
- enable?: boolean;
226
- run?: boolean;
227
- debug?: boolean;
228
- implementations?: boolean;
229
- refs?: boolean;
230
- methodReferences?: boolean;
231
- references?: boolean;
232
- enumVariantReferences?: boolean;
233
- };
234
- hover?: {
235
- documentation?: boolean;
236
- keywords?: boolean;
237
- linksInHover?: boolean;
238
- memoryLayout?: {
239
- enable?: boolean;
240
- };
241
- };
242
- workspace?: {
243
- symbol?: {
244
- search?: {
245
- scope?: 'workspace' | 'workspace_and_dependencies';
246
- kind?: 'only_types' | 'all_symbols';
247
- };
248
- };
249
- };
250
- }
251
- /**
252
- * Initialization options for TypeScript/JavaScript language server
253
- * @see https://github.com/typescript-language-server/typescript-language-server
254
- */
255
- export interface TypeScriptInitializationOptions {
256
- hostInfo?: string;
257
- npmLocation?: string;
258
- globalPlugins?: string[];
259
- pluginProbeLocations?: string[];
260
- preferences?: {
261
- includePackageJsonAutoImports?: 'auto' | 'on' | 'off';
262
- providePrefixAndSuffixTextForRename?: boolean;
263
- allowRenameOfImportPath?: boolean;
264
- includeAutomaticOptionalChainCompletions?: boolean;
265
- includeCompletionsForModuleExports?: boolean;
266
- includeCompletionsForImportStatements?: boolean;
267
- includeCompletionsWithSnippetText?: boolean;
268
- includeCompletionsWithInsertText?: boolean;
269
- allowIncompleteCompletions?: boolean;
270
- importModuleSpecifier?: 'shortest' | 'relative' | 'absolute' | 'auto';
271
- importModuleSpecifierEnding?: 'minimal' | 'index' | 'js';
272
- allowTextChangesInNewFiles?: boolean;
273
- lazyConfiguredProjectsFromExternalProject?: boolean;
274
- providePrefixAndSuffixTextForQuickInfo?: boolean;
275
- includeInlayParameterNameHints?: 'none' | 'literals' | 'all';
276
- includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
277
- includeInlayFunctionParameterTypeHints?: boolean;
278
- includeInlayVariableTypeHints?: boolean;
279
- includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
280
- includeInlayPropertyDeclarationTypeHints?: boolean;
281
- includeInlayFunctionLikeReturnTypeHints?: boolean;
282
- includeInlayEnumMemberValueHints?: boolean;
283
- };
284
- locale?: string;
285
- maxTsServerMemory?: number;
286
- tsserver?: {
287
- logLevel?: 'off' | 'terse' | 'normal' | 'requestTime' | 'verbose';
288
- logVerbosity?: 'off' | 'terse' | 'normal' | 'requestTime' | 'verbose';
289
- trace?: 'off' | 'messages' | 'verbose';
290
- useSeparateSyntaxServer?: boolean;
291
- enableTracing?: boolean;
292
- path?: string;
293
- };
294
- }
295
- /**
296
- * Initialization options for ESLint language server
297
- * @see https://github.com/Microsoft/vscode-eslint
298
- */
299
- export interface ESLintInitializationOptions {
300
- packageManager?: 'npm' | 'yarn' | 'pnpm';
301
- nodePath?: string;
302
- options?: Record<string, any>;
303
- rules?: Record<string, any>;
304
- rulesCustomizations?: Array<{
305
- rule: string;
306
- severity: 'downgrade' | 'upgrade' | 'info' | 'warn' | 'error' | 'off';
307
- }>;
308
- run?: 'onType' | 'onSave';
309
- problems?: {
310
- shortenToSingleLine?: boolean;
311
- };
312
- codeAction?: {
313
- disableRuleComment?: {
314
- enable?: boolean;
315
- location?: 'separateLine' | 'sameLine';
316
- };
317
- showDocumentation?: {
318
- enable?: boolean;
319
- };
320
- };
321
- codeActionOnSave?: {
322
- enable?: boolean;
323
- mode?: 'all' | 'problems';
324
- };
325
- format?: {
326
- enable?: boolean;
327
- };
328
- quiet?: boolean;
329
- onIgnoredFiles?: 'off' | 'warn';
330
- useESLintClass?: boolean;
331
- experimental?: {
332
- useFlatConfig?: boolean;
333
- };
334
- workingDirectory?: {
335
- mode?: 'auto' | 'location';
336
- };
337
- }
338
- /**
339
- * Initialization options for Clangd language server
340
- * @see https://clangd.llvm.org/config
341
- */
342
- export interface ClangdInitializationOptions {
343
- compilationDatabasePath?: string;
344
- compilationDatabaseChanges?: Record<string, any>;
345
- fallbackFlags?: string[];
346
- clangdFileStatus?: boolean;
347
- utf8?: boolean;
348
- offsetEncoding?: ('utf-8' | 'utf-16' | 'utf-32')[];
349
- index?: {
350
- background?: 'Build' | 'Skip';
351
- threads?: number;
352
- };
353
- completion?: {
354
- detailedLabel?: boolean;
355
- allScopes?: boolean;
356
- };
357
- hover?: {
358
- showAKA?: boolean;
359
- };
360
- inlayHints?: {
361
- enabled?: boolean;
362
- parameterNames?: boolean;
363
- deducedTypes?: boolean;
364
- designators?: boolean;
365
- };
366
- semanticHighlighting?: boolean;
367
- diagnostics?: {
368
- unusedIncludes?: 'None' | 'Strict';
369
- missingIncludes?: 'None' | 'Strict';
370
- clangTidy?: boolean;
371
- suppressAll?: boolean;
372
- };
373
- }
374
- /**
375
- * Initialization options for Gopls (Go language server)
376
- * @see https://github.com/golang/tools/blob/master/gopls/doc/settings.md
377
- */
378
- export interface GoplsInitializationOptions {
379
- buildFlags?: string[];
380
- env?: Record<string, string>;
381
- directoryFilters?: string[];
382
- templateExtensions?: string[];
383
- memoryMode?: 'DegradeClosed' | 'Normal';
384
- gofumpt?: boolean;
385
- staticcheck?: boolean;
386
- analyses?: Record<string, boolean>;
387
- codelenses?: Record<string, boolean>;
388
- usePlaceholders?: boolean;
389
- completionBudget?: string;
390
- diagnosticsDelay?: string;
391
- experimentalPostfixCompletions?: boolean;
392
- experimentalWorkspaceModule?: boolean;
393
- experimentalTemplateSupport?: boolean;
394
- semanticTokens?: boolean;
395
- noSemanticString?: boolean;
396
- noSemanticNumber?: boolean;
397
- expandWorkspaceToModule?: boolean;
398
- experimentalUseInvalidMetadata?: boolean;
399
- hoverKind?: 'FullDocumentation' | 'NoDocumentation' | 'SingleLine' | 'Structured' | 'SynopsisDocumentation';
400
- linkTarget?: string;
401
- linksInHover?: boolean;
402
- importShortcut?: 'Both' | 'Definition' | 'Link';
403
- symbolMatcher?: 'CaseInsensitive' | 'CaseSensitive' | 'FastFuzzy' | 'Fuzzy';
404
- symbolStyle?: 'Dynamic' | 'Full' | 'Package';
405
- verboseOutput?: boolean;
406
- }
407
162
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemirror-languageserver",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Language Server Plugin for CodeMirror 6",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",