codemirror-languageserver 1.14.0 → 1.16.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.
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Initialization options for Pyright language server
3
+ * @see https://github.com/microsoft/pyright/blob/main/docs/settings.md
4
+ */
5
+ export interface PyrightInitializationOptions {
6
+ python?: {
7
+ pythonPath?: string;
8
+ venvPath?: string;
9
+ analysis?: {
10
+ autoSearchPaths?: boolean;
11
+ extraPaths?: string[];
12
+ diagnosticMode?: 'workspace' | 'openFilesOnly';
13
+ stubPath?: string;
14
+ typeshedPaths?: string[];
15
+ useLibraryCodeForTypes?: boolean;
16
+ typeCheckingMode?: 'off' | 'basic' | 'strict';
17
+ autoImportCompletions?: boolean;
18
+ indexing?: boolean;
19
+ };
20
+ };
21
+ reportMissingImports?: boolean;
22
+ reportMissingTypeStubs?: boolean;
23
+ reportMissingModuleSource?: boolean;
24
+ reportInvalidTypeVarUse?: boolean;
25
+ reportOptionalSubscript?: boolean;
26
+ reportOptionalMemberAccess?: boolean;
27
+ reportOptionalCall?: boolean;
28
+ reportOptionalIterable?: boolean;
29
+ reportOptionalContextManager?: boolean;
30
+ reportOptionalOperand?: boolean;
31
+ reportTypedDictNotRequiredAccess?: boolean;
32
+ reportPrivateImportUsage?: boolean;
33
+ reportConstantRedefinition?: boolean;
34
+ reportIncompatibleMethodOverride?: boolean;
35
+ reportIncompatibleVariableOverride?: boolean;
36
+ reportInconsistentConstructor?: boolean;
37
+ }
38
+ /**
39
+ * Initialization options for Rust Analyzer language server
40
+ * @see https://rust-analyzer.github.io/manual.html#configuration
41
+ */
42
+ export interface RustAnalyzerInitializationOptions {
43
+ cargo?: {
44
+ buildScripts?: {
45
+ enable?: boolean;
46
+ invocationStrategy?: 'per_workspace' | 'once';
47
+ invocationLocation?: 'workspace' | 'root';
48
+ };
49
+ allTargets?: boolean;
50
+ noDefaultFeatures?: boolean;
51
+ allFeatures?: boolean;
52
+ features?: string[];
53
+ target?: string;
54
+ runBuildScripts?: boolean;
55
+ useRustcWrapperForBuildScripts?: boolean;
56
+ };
57
+ procMacro?: {
58
+ enable?: boolean;
59
+ ignored?: Record<string, string[]>;
60
+ server?: string;
61
+ attributes?: {
62
+ enable?: boolean;
63
+ };
64
+ };
65
+ diagnostics?: {
66
+ enable?: boolean;
67
+ disabled?: string[];
68
+ warningsAsHint?: string[];
69
+ warningsAsInfo?: string[];
70
+ remapPrefix?: Record<string, string>;
71
+ experimental?: {
72
+ enable?: boolean;
73
+ };
74
+ };
75
+ completion?: {
76
+ addCallArgumentSnippets?: boolean;
77
+ addCallParenthesis?: boolean;
78
+ postfix?: {
79
+ enable?: boolean;
80
+ };
81
+ autoimport?: {
82
+ enable?: boolean;
83
+ };
84
+ privateEditable?: {
85
+ enable?: boolean;
86
+ };
87
+ };
88
+ assist?: {
89
+ importGranularity?: 'preserve' | 'crate' | 'module' | 'item';
90
+ importEnforceGranularity?: boolean;
91
+ importPrefix?: 'plain' | 'by_self' | 'by_crate';
92
+ allowMergingIntoGlobImports?: boolean;
93
+ };
94
+ callInfo?: {
95
+ full?: boolean;
96
+ };
97
+ lens?: {
98
+ enable?: boolean;
99
+ run?: boolean;
100
+ debug?: boolean;
101
+ implementations?: boolean;
102
+ refs?: boolean;
103
+ methodReferences?: boolean;
104
+ references?: boolean;
105
+ enumVariantReferences?: boolean;
106
+ };
107
+ hover?: {
108
+ documentation?: boolean;
109
+ keywords?: boolean;
110
+ linksInHover?: boolean;
111
+ memoryLayout?: {
112
+ enable?: boolean;
113
+ };
114
+ };
115
+ workspace?: {
116
+ symbol?: {
117
+ search?: {
118
+ scope?: 'workspace' | 'workspace_and_dependencies';
119
+ kind?: 'only_types' | 'all_symbols';
120
+ };
121
+ };
122
+ };
123
+ }
124
+ /**
125
+ * Initialization options for TypeScript/JavaScript language server
126
+ * @see https://github.com/typescript-language-server/typescript-language-server
127
+ */
128
+ export interface TypeScriptInitializationOptions {
129
+ hostInfo?: string;
130
+ npmLocation?: string;
131
+ globalPlugins?: string[];
132
+ pluginProbeLocations?: string[];
133
+ preferences?: {
134
+ includePackageJsonAutoImports?: 'auto' | 'on' | 'off';
135
+ providePrefixAndSuffixTextForRename?: boolean;
136
+ allowRenameOfImportPath?: boolean;
137
+ includeAutomaticOptionalChainCompletions?: boolean;
138
+ includeCompletionsForModuleExports?: boolean;
139
+ includeCompletionsForImportStatements?: boolean;
140
+ includeCompletionsWithSnippetText?: boolean;
141
+ includeCompletionsWithInsertText?: boolean;
142
+ allowIncompleteCompletions?: boolean;
143
+ importModuleSpecifier?: 'shortest' | 'relative' | 'absolute' | 'auto';
144
+ importModuleSpecifierEnding?: 'minimal' | 'index' | 'js';
145
+ allowTextChangesInNewFiles?: boolean;
146
+ lazyConfiguredProjectsFromExternalProject?: boolean;
147
+ providePrefixAndSuffixTextForQuickInfo?: boolean;
148
+ includeInlayParameterNameHints?: 'none' | 'literals' | 'all';
149
+ includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
150
+ includeInlayFunctionParameterTypeHints?: boolean;
151
+ includeInlayVariableTypeHints?: boolean;
152
+ includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
153
+ includeInlayPropertyDeclarationTypeHints?: boolean;
154
+ includeInlayFunctionLikeReturnTypeHints?: boolean;
155
+ includeInlayEnumMemberValueHints?: boolean;
156
+ };
157
+ locale?: string;
158
+ maxTsServerMemory?: number;
159
+ tsserver?: {
160
+ logLevel?: 'off' | 'terse' | 'normal' | 'requestTime' | 'verbose';
161
+ logVerbosity?: 'off' | 'terse' | 'normal' | 'requestTime' | 'verbose';
162
+ trace?: 'off' | 'messages' | 'verbose';
163
+ useSeparateSyntaxServer?: boolean;
164
+ enableTracing?: boolean;
165
+ path?: string;
166
+ };
167
+ }
168
+ /**
169
+ * Initialization options for ESLint language server
170
+ * @see https://github.com/Microsoft/vscode-eslint
171
+ */
172
+ export interface ESLintInitializationOptions {
173
+ packageManager?: 'npm' | 'yarn' | 'pnpm';
174
+ nodePath?: string;
175
+ options?: Record<string, any>;
176
+ rules?: Record<string, any>;
177
+ rulesCustomizations?: Array<{
178
+ rule: string;
179
+ severity: 'downgrade' | 'upgrade' | 'info' | 'warn' | 'error' | 'off';
180
+ }>;
181
+ run?: 'onType' | 'onSave';
182
+ problems?: {
183
+ shortenToSingleLine?: boolean;
184
+ };
185
+ codeAction?: {
186
+ disableRuleComment?: {
187
+ enable?: boolean;
188
+ location?: 'separateLine' | 'sameLine';
189
+ };
190
+ showDocumentation?: {
191
+ enable?: boolean;
192
+ };
193
+ };
194
+ codeActionOnSave?: {
195
+ enable?: boolean;
196
+ mode?: 'all' | 'problems';
197
+ };
198
+ format?: {
199
+ enable?: boolean;
200
+ };
201
+ quiet?: boolean;
202
+ onIgnoredFiles?: 'off' | 'warn';
203
+ useESLintClass?: boolean;
204
+ experimental?: {
205
+ useFlatConfig?: boolean;
206
+ };
207
+ workingDirectory?: {
208
+ mode?: 'auto' | 'location';
209
+ };
210
+ }
211
+ /**
212
+ * Initialization options for Clangd language server
213
+ * @see https://clangd.llvm.org/config
214
+ */
215
+ export interface ClangdInitializationOptions {
216
+ compilationDatabasePath?: string;
217
+ compilationDatabaseChanges?: Record<string, any>;
218
+ fallbackFlags?: string[];
219
+ clangdFileStatus?: boolean;
220
+ utf8?: boolean;
221
+ offsetEncoding?: ('utf-8' | 'utf-16' | 'utf-32')[];
222
+ index?: {
223
+ background?: 'Build' | 'Skip';
224
+ threads?: number;
225
+ };
226
+ completion?: {
227
+ detailedLabel?: boolean;
228
+ allScopes?: boolean;
229
+ };
230
+ hover?: {
231
+ showAKA?: boolean;
232
+ };
233
+ inlayHints?: {
234
+ enabled?: boolean;
235
+ parameterNames?: boolean;
236
+ deducedTypes?: boolean;
237
+ designators?: boolean;
238
+ };
239
+ semanticHighlighting?: boolean;
240
+ diagnostics?: {
241
+ unusedIncludes?: 'None' | 'Strict';
242
+ missingIncludes?: 'None' | 'Strict';
243
+ clangTidy?: boolean;
244
+ suppressAll?: boolean;
245
+ };
246
+ }
247
+ /**
248
+ * Initialization options for Gopls (Go language server)
249
+ * @see https://github.com/golang/tools/blob/master/gopls/doc/settings.md
250
+ */
251
+ export interface GoplsInitializationOptions {
252
+ buildFlags?: string[];
253
+ env?: Record<string, string>;
254
+ directoryFilters?: string[];
255
+ templateExtensions?: string[];
256
+ memoryMode?: 'DegradeClosed' | 'Normal';
257
+ gofumpt?: boolean;
258
+ staticcheck?: boolean;
259
+ analyses?: Record<string, boolean>;
260
+ codelenses?: Record<string, boolean>;
261
+ usePlaceholders?: boolean;
262
+ completionBudget?: string;
263
+ diagnosticsDelay?: string;
264
+ experimentalPostfixCompletions?: boolean;
265
+ experimentalWorkspaceModule?: boolean;
266
+ experimentalTemplateSupport?: boolean;
267
+ semanticTokens?: boolean;
268
+ noSemanticString?: boolean;
269
+ noSemanticNumber?: boolean;
270
+ expandWorkspaceToModule?: boolean;
271
+ experimentalUseInvalidMetadata?: boolean;
272
+ hoverKind?: 'FullDocumentation' | 'NoDocumentation' | 'SingleLine' | 'Structured' | 'SynopsisDocumentation';
273
+ linkTarget?: string;
274
+ linksInHover?: boolean;
275
+ importShortcut?: 'Both' | 'Definition' | 'Link';
276
+ symbolMatcher?: 'CaseInsensitive' | 'CaseSensitive' | 'FastFuzzy' | 'Fuzzy';
277
+ symbolStyle?: 'Dynamic' | 'Full' | 'Package';
278
+ verboseOutput?: boolean;
279
+ }
@@ -0,0 +1,2 @@
1
+ import { Extension } from '@codemirror/state';
2
+ export declare const mouseHandler: () => Extension;
@@ -0,0 +1,160 @@
1
+ import { EditorView, Tooltip, ViewPlugin } from '@codemirror/view';
2
+ import { CompletionTriggerKind } from 'vscode-languageserver-protocol';
3
+ import type { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
4
+ import type { PluginValue, ViewUpdate } from '@codemirror/view';
5
+ import { Transport } from '@open-rpc/client-js/build/transports/Transport';
6
+ import type { PublishDiagnosticsParams } from 'vscode-languageserver-protocol';
7
+ import type * as LSP from 'vscode-languageserver-protocol';
8
+ interface LSPRequestMap {
9
+ initialize: [LSP.InitializeParams, LSP.InitializeResult];
10
+ 'textDocument/hover': [LSP.HoverParams, LSP.Hover];
11
+ 'textDocument/completion': [
12
+ LSP.CompletionParams,
13
+ LSP.CompletionItem[] | LSP.CompletionList | null
14
+ ];
15
+ 'textDocument/definition': [
16
+ LSP.DefinitionParams,
17
+ LSP.Location | LSP.Location[] | LSP.LocationLink[] | null
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
+ }
28
+ interface LSPNotifyMap {
29
+ initialized: LSP.InitializedParams;
30
+ 'textDocument/didChange': LSP.DidChangeTextDocumentParams;
31
+ 'textDocument/didOpen': LSP.DidOpenTextDocumentParams;
32
+ }
33
+ interface LSPEventMap {
34
+ 'textDocument/publishDiagnostics': LSP.PublishDiagnosticsParams;
35
+ }
36
+ type Notification = {
37
+ [key in keyof LSPEventMap]: {
38
+ jsonrpc: '2.0';
39
+ id?: null | undefined;
40
+ method: key;
41
+ params: LSPEventMap[key];
42
+ };
43
+ }[keyof LSPEventMap];
44
+ interface LanguageServerClientLocationMethods {
45
+ textDocumentDefinition(params: LSP.DefinitionParams): LSP.Location | LSP.Location[] | LSP.LocationLink[] | null;
46
+ textDocumentDeclaration(params: LSP.DeclarationParams): LSP.Location | LSP.Location[] | LSP.LocationLink[] | null;
47
+ textDocumentTypeDefinition(params: LSP.TypeDefinitionParams): LSP.Location | LSP.Location[] | LSP.LocationLink[] | null;
48
+ }
49
+ export declare class LanguageServerClient<InitializationOptions = unknown> {
50
+ ready: boolean;
51
+ capabilities: LSP.ServerCapabilities<any>;
52
+ initializePromise: Promise<void>;
53
+ private rootUri;
54
+ private workspaceFolders;
55
+ private autoClose?;
56
+ private transport;
57
+ private requestManager;
58
+ private client;
59
+ private plugins;
60
+ private options;
61
+ constructor(options: LanguageServerClientOptions<InitializationOptions>);
62
+ protected getInitializeParams(): LSP.InitializeParams;
63
+ initialize(): Promise<void>;
64
+ close(): void;
65
+ textDocumentDidOpen(params: LSP.DidOpenTextDocumentParams): Promise<LSP.DidOpenTextDocumentParams>;
66
+ textDocumentDidChange(params: LSP.DidChangeTextDocumentParams): Promise<LSP.DidChangeTextDocumentParams>;
67
+ textDocumentHover(params: LSP.HoverParams): Promise<LSP.Hover>;
68
+ textDocumentCompletion(params: LSP.CompletionParams): Promise<LSP.CompletionList | LSP.CompletionItem[]>;
69
+ textDocumentDefinition(params: LSP.DefinitionParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
70
+ textDocumentDeclaration(params: LSP.DeclarationParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
71
+ textDocumentTypeDefinition(params: LSP.TypeDefinitionParams): Promise<LSP.Location | LSP.Location[] | LSP.LocationLink[]>;
72
+ attachPlugin(plugin: LanguageServerPlugin): void;
73
+ detachPlugin(plugin: LanguageServerPlugin): void;
74
+ protected request<K extends keyof LSPRequestMap>(method: K, params: LSPRequestMap[K][0], timeout: number): Promise<LSPRequestMap[K][1]>;
75
+ protected notify<K extends keyof LSPNotifyMap>(method: K, params: LSPNotifyMap[K]): Promise<LSPNotifyMap[K]>;
76
+ protected processNotification(notification: Notification): void;
77
+ }
78
+ export declare class LanguageServerPlugin implements PluginValue {
79
+ private view;
80
+ client: LanguageServerClient;
81
+ private documentUri;
82
+ private languageId;
83
+ private documentVersion;
84
+ private allowHTMLContent;
85
+ private changesTimeout;
86
+ constructor(view: EditorView, { client, documentUri, languageId, allowHTMLContent, }: {
87
+ client: LanguageServerClient;
88
+ documentUri: string;
89
+ languageId: string;
90
+ allowHTMLContent: boolean;
91
+ });
92
+ update({ docChanged }: ViewUpdate): void;
93
+ destroy(): void;
94
+ initialize({ documentText }: {
95
+ documentText: string;
96
+ }): Promise<void>;
97
+ sendChange({ documentText }: {
98
+ documentText: string;
99
+ }): Promise<void>;
100
+ requestDiagnostics(view: EditorView): void;
101
+ requestHoverTooltip(view: EditorView, { line, character }: {
102
+ line: number;
103
+ character: number;
104
+ }): Promise<Tooltip | null>;
105
+ requestCompletion(context: CompletionContext, { line, character }: {
106
+ line: number;
107
+ character: number;
108
+ }, { triggerKind, triggerCharacter, }: {
109
+ triggerKind: CompletionTriggerKind;
110
+ triggerCharacter: string | undefined;
111
+ }): Promise<CompletionResult | null>;
112
+ requestLocation(view: EditorView, { line, character }: {
113
+ line: number;
114
+ character: number;
115
+ }, capability: keyof LSP.ServerCapabilities<any>, method: keyof LanguageServerClientLocationMethods): Promise<{
116
+ uri: string;
117
+ range: LSP.Range;
118
+ }>;
119
+ requestDefinition(view: EditorView, { line, character }: {
120
+ line: number;
121
+ character: number;
122
+ }): Promise<{
123
+ uri: string;
124
+ range: LSP.Range;
125
+ }>;
126
+ requestDeclaration(view: EditorView, { line, character }: {
127
+ line: number;
128
+ character: number;
129
+ }): Promise<{
130
+ uri: string;
131
+ range: LSP.Range;
132
+ }>;
133
+ requestTypeDefinition(view: EditorView, { line, character }: {
134
+ line: number;
135
+ character: number;
136
+ }): Promise<{
137
+ uri: string;
138
+ range: LSP.Range;
139
+ }>;
140
+ processNotification(notification: Notification): void;
141
+ processDiagnostics(params: PublishDiagnosticsParams): void;
142
+ }
143
+ export declare const languageServerPlugin: ViewPlugin<LanguageServerPlugin, {
144
+ client: LanguageServerClient;
145
+ documentUri: string;
146
+ languageId: string;
147
+ allowHTMLContent: boolean;
148
+ }>;
149
+ export interface LanguageServerBaseOptions {
150
+ rootUri: string | null;
151
+ workspaceFolders: LSP.WorkspaceFolder[] | null;
152
+ documentUri: string;
153
+ languageId: string;
154
+ }
155
+ export interface LanguageServerClientOptions<InitializationOptions = unknown> extends LanguageServerBaseOptions {
156
+ transport: Transport;
157
+ autoClose?: boolean;
158
+ initializationOptions?: InitializationOptions;
159
+ }
160
+ export {};
package/dist/pos.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { Text } from '@codemirror/state';
2
+ export declare function posToOffset(doc: Text, pos: {
3
+ line: number;
4
+ character: number;
5
+ }): number;
6
+ export declare function offsetToPos(doc: Text, offset: number): {
7
+ character: number;
8
+ line: number;
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemirror-languageserver",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Language Server Plugin for CodeMirror 6",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",