@difizen/libro-lsp 0.1.2
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/LICENSE +21 -0
- package/README.md +0 -0
- package/es/adapters/adapter.d.ts +255 -0
- package/es/adapters/adapter.d.ts.map +1 -0
- package/es/adapters/adapter.js +647 -0
- package/es/adapters/notebook-adapter.d.ts +150 -0
- package/es/adapters/notebook-adapter.d.ts.map +1 -0
- package/es/adapters/notebook-adapter.js +588 -0
- package/es/adapters/status-message.d.ts +48 -0
- package/es/adapters/status-message.d.ts.map +1 -0
- package/es/adapters/status-message.js +110 -0
- package/es/connection-manager.d.ts +199 -0
- package/es/connection-manager.d.ts.map +1 -0
- package/es/connection-manager.js +685 -0
- package/es/connection.d.ts +149 -0
- package/es/connection.d.ts.map +1 -0
- package/es/connection.js +591 -0
- package/es/extractors/index.d.ts +4 -0
- package/es/extractors/index.d.ts.map +1 -0
- package/es/extractors/index.js +6 -0
- package/es/extractors/manager.d.ts +31 -0
- package/es/extractors/manager.d.ts.map +1 -0
- package/es/extractors/manager.js +90 -0
- package/es/extractors/text-extractor.d.ts +56 -0
- package/es/extractors/text-extractor.d.ts.map +1 -0
- package/es/extractors/text-extractor.js +72 -0
- package/es/extractors/types.d.ts +68 -0
- package/es/extractors/types.d.ts.map +1 -0
- package/es/extractors/types.js +1 -0
- package/es/feature.d.ts +29 -0
- package/es/feature.d.ts.map +1 -0
- package/es/feature.js +85 -0
- package/es/index.d.ts +19 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +21 -0
- package/es/lsp-app-contribution.d.ts +19 -0
- package/es/lsp-app-contribution.d.ts.map +1 -0
- package/es/lsp-app-contribution.js +155 -0
- package/es/lsp-protocol.d.ts +10 -0
- package/es/lsp-protocol.d.ts.map +1 -0
- package/es/lsp-protocol.js +1 -0
- package/es/lsp.d.ts +136 -0
- package/es/lsp.d.ts.map +1 -0
- package/es/lsp.js +141 -0
- package/es/manager.d.ts +142 -0
- package/es/manager.d.ts.map +1 -0
- package/es/manager.js +423 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +21 -0
- package/es/plugin.d.ts +56 -0
- package/es/plugin.d.ts.map +1 -0
- package/es/plugin.js +0 -0
- package/es/positioning.d.ts +66 -0
- package/es/positioning.d.ts.map +1 -0
- package/es/positioning.js +96 -0
- package/es/schema.d.ts +240 -0
- package/es/schema.d.ts.map +1 -0
- package/es/schema.js +0 -0
- package/es/tokens.d.ts +677 -0
- package/es/tokens.d.ts.map +1 -0
- package/es/tokens.js +183 -0
- package/es/utils.d.ts +33 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +168 -0
- package/es/virtual/document.d.ts +546 -0
- package/es/virtual/document.d.ts.map +1 -0
- package/es/virtual/document.js +1263 -0
- package/es/ws-connection/server-capability-registration.d.ts +19 -0
- package/es/ws-connection/server-capability-registration.d.ts.map +1 -0
- package/es/ws-connection/server-capability-registration.js +51 -0
- package/es/ws-connection/types.d.ts +76 -0
- package/es/ws-connection/types.d.ts.map +1 -0
- package/es/ws-connection/types.js +1 -0
- package/es/ws-connection/ws-connection.d.ts +105 -0
- package/es/ws-connection/ws-connection.d.ts.map +1 -0
- package/es/ws-connection/ws-connection.js +301 -0
- package/package.json +67 -0
- package/src/adapters/adapter.ts +611 -0
- package/src/adapters/notebook-adapter.ts +463 -0
- package/src/adapters/status-message.ts +93 -0
- package/src/connection-manager.ts +626 -0
- package/src/connection.ts +570 -0
- package/src/extractors/index.ts +6 -0
- package/src/extractors/manager.ts +82 -0
- package/src/extractors/text-extractor.ts +94 -0
- package/src/extractors/types.ts +78 -0
- package/src/feature.ts +60 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +21 -0
- package/src/lsp-app-contribution.ts +83 -0
- package/src/lsp-protocol.ts +10 -0
- package/src/lsp.ts +160 -0
- package/src/manager.ts +358 -0
- package/src/module.ts +32 -0
- package/src/plugin.ts +62 -0
- package/src/positioning.ts +121 -0
- package/src/schema.ts +249 -0
- package/src/tokens.ts +843 -0
- package/src/utils.ts +109 -0
- package/src/virtual/document.ts +1250 -0
- package/src/ws-connection/server-capability-registration.ts +77 -0
- package/src/ws-connection/types.ts +102 -0
- package/src/ws-connection/ws-connection.ts +320 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import type { LanguageIdentifier } from '../lsp.js';
|
|
5
|
+
import { positionAtOffset } from '../positioning.js';
|
|
6
|
+
|
|
7
|
+
import type { IExtractedCode, IForeignCodeExtractor } from './types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The code extractor for the raw and markdown text.
|
|
11
|
+
*/
|
|
12
|
+
export class TextForeignCodeExtractor implements IForeignCodeExtractor {
|
|
13
|
+
constructor(options: TextForeignCodeExtractor.IOptions) {
|
|
14
|
+
this.language = options.language;
|
|
15
|
+
this.standalone = options.isStandalone;
|
|
16
|
+
this.fileExtension = options.file_extension;
|
|
17
|
+
this.cellType = options.cellType;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The foreign language.
|
|
21
|
+
*/
|
|
22
|
+
readonly language: LanguageIdentifier;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Should the foreign code be appended (False) to the previously established virtual document of the same language,
|
|
26
|
+
* or is it standalone snippet which requires separate connection?
|
|
27
|
+
*/
|
|
28
|
+
readonly standalone: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
32
|
+
*/
|
|
33
|
+
readonly fileExtension: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The supported cell types.
|
|
37
|
+
*/
|
|
38
|
+
readonly cellType: string[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Test if there is any foreign code in provided code snippet.
|
|
42
|
+
*/
|
|
43
|
+
hasForeignCode(code: string, cellType: string): boolean {
|
|
44
|
+
return this.cellType.includes(cellType);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Split the code into the host and foreign code (if any foreign code was detected)
|
|
49
|
+
*/
|
|
50
|
+
extractForeignCode(code: string): IExtractedCode[] {
|
|
51
|
+
const lines = code.split('\n');
|
|
52
|
+
|
|
53
|
+
const extracts = new Array<IExtractedCode>();
|
|
54
|
+
|
|
55
|
+
const foreignCodeFragment = code;
|
|
56
|
+
|
|
57
|
+
const start = positionAtOffset(0, lines);
|
|
58
|
+
const end = positionAtOffset(foreignCodeFragment.length, lines);
|
|
59
|
+
|
|
60
|
+
extracts.push({
|
|
61
|
+
hostCode: '',
|
|
62
|
+
foreignCode: foreignCodeFragment,
|
|
63
|
+
range: { start, end },
|
|
64
|
+
virtualShift: null,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return extracts;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
namespace TextForeignCodeExtractor {
|
|
72
|
+
export interface IOptions {
|
|
73
|
+
/**
|
|
74
|
+
* The foreign language.
|
|
75
|
+
*/
|
|
76
|
+
language: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Should the foreign code be appended (False) to the previously established virtual document of the same language,
|
|
80
|
+
* or is it standalone snippet which requires separate connection?
|
|
81
|
+
*/
|
|
82
|
+
isStandalone: boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
86
|
+
*/
|
|
87
|
+
file_extension: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The supported cell types.
|
|
91
|
+
*/
|
|
92
|
+
cellType: string[];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import type { IRange, IPosition } from '@difizen/libro-code-editor';
|
|
5
|
+
|
|
6
|
+
import type { LanguageIdentifier } from '../lsp.js';
|
|
7
|
+
|
|
8
|
+
export interface IExtractedCode {
|
|
9
|
+
/**
|
|
10
|
+
* Foreign code (may be empty, for example line of '%R') or null if none.
|
|
11
|
+
*/
|
|
12
|
+
foreignCode: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Range of the foreign code relative to the original source.
|
|
15
|
+
* `null` is used internally to represent a leftover host code after extraction.
|
|
16
|
+
*/
|
|
17
|
+
range: IRange | null;
|
|
18
|
+
/**
|
|
19
|
+
* Shift due to any additional code inserted at the beginning of the virtual document
|
|
20
|
+
* (usually in order to mock the arguments passed to a magic, or to provide other context clues for the linters)
|
|
21
|
+
*/
|
|
22
|
+
virtualShift: IPosition | null;
|
|
23
|
+
/**
|
|
24
|
+
* Code to be retained in the virtual document of the host.
|
|
25
|
+
*/
|
|
26
|
+
hostCode: string | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Foreign code extractor makes it possible to analyze code of language X embedded in code (or notebook) of language Y.
|
|
31
|
+
*
|
|
32
|
+
* The typical examples are:
|
|
33
|
+
* - (X=CSS< Y=HTML), or
|
|
34
|
+
* - (X=JavaScript, Y=HTML),
|
|
35
|
+
*
|
|
36
|
+
* while in the data analysis realm, examples include:
|
|
37
|
+
* - (X=R, Y=IPython),
|
|
38
|
+
* - (X=LATEX Y=IPython),
|
|
39
|
+
* - (X=SQL, Y=IPython)
|
|
40
|
+
*
|
|
41
|
+
* This extension does not aim to provide comprehensive abilities for foreign code extraction,
|
|
42
|
+
* but it does intend to provide stable interface for other extensions to build on it.
|
|
43
|
+
*
|
|
44
|
+
* A simple, regular expression based, configurable foreign extractor is implemented
|
|
45
|
+
* to provide a good reference and a good initial experience for the users.
|
|
46
|
+
*/
|
|
47
|
+
export interface IForeignCodeExtractor {
|
|
48
|
+
/**
|
|
49
|
+
* The foreign language.
|
|
50
|
+
*/
|
|
51
|
+
readonly language: LanguageIdentifier;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The supported cell types.
|
|
55
|
+
*/
|
|
56
|
+
readonly cellType: string[];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Split the code into the host and foreign code (if any foreign code was detected)
|
|
60
|
+
*/
|
|
61
|
+
extractForeignCode(code: string): IExtractedCode[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Does the extractor produce code which should be appended to the previously established virtual document (False)
|
|
65
|
+
* of the same language, or does it produce standalone snippets which require separate connections (True)?
|
|
66
|
+
*/
|
|
67
|
+
readonly standalone: boolean;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Test if there is any foreign code in provided code snippet.
|
|
71
|
+
*/
|
|
72
|
+
hasForeignCode(code: string, cellType: string): boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
76
|
+
*/
|
|
77
|
+
readonly fileExtension: string;
|
|
78
|
+
}
|
package/src/feature.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import type { Event } from '@difizen/mana-app';
|
|
5
|
+
import { Emitter } from '@difizen/mana-app';
|
|
6
|
+
import { singleton } from '@difizen/mana-app';
|
|
7
|
+
import mergeWith from 'lodash.mergewith';
|
|
8
|
+
|
|
9
|
+
import type { ClientCapabilities } from './lsp.js';
|
|
10
|
+
import type { IFeature } from './tokens.js';
|
|
11
|
+
import { ILSPFeatureManager } from './tokens.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Class to manager the registered features of the language servers.
|
|
15
|
+
*/
|
|
16
|
+
@singleton({ token: ILSPFeatureManager })
|
|
17
|
+
export class FeatureManager implements ILSPFeatureManager {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._featuresRegistered = new Emitter();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* List of registered features
|
|
23
|
+
*/
|
|
24
|
+
readonly features: IFeature[] = [];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Signal emitted when a new feature is registered.
|
|
28
|
+
*/
|
|
29
|
+
get featuresRegistered(): Event<IFeature> {
|
|
30
|
+
return this._featuresRegistered.event;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Register a new feature, skip if it is already registered.
|
|
35
|
+
*/
|
|
36
|
+
register(feature: IFeature): void {
|
|
37
|
+
if (this.features.some((ft) => ft.id === feature.id)) {
|
|
38
|
+
console.warn(`Feature with id ${feature.id} is already registered, skipping.`);
|
|
39
|
+
} else {
|
|
40
|
+
this.features.push(feature);
|
|
41
|
+
this._featuresRegistered.fire(feature);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the capabilities of all clients.
|
|
47
|
+
*/
|
|
48
|
+
clientCapabilities(): ClientCapabilities {
|
|
49
|
+
let capabilities: ClientCapabilities = {};
|
|
50
|
+
for (const feature of this.features) {
|
|
51
|
+
if (!feature.capabilities) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
capabilities = mergeWith(capabilities, feature.capabilities);
|
|
55
|
+
}
|
|
56
|
+
return capabilities;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected _featuresRegistered: Emitter<IFeature>;
|
|
60
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module lsp
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './module.js';
|
|
9
|
+
export * from './adapters/adapter.js';
|
|
10
|
+
export * from './connection-manager.js';
|
|
11
|
+
export * from './extractors/index.js';
|
|
12
|
+
export * from './feature.js';
|
|
13
|
+
export * from './manager.js';
|
|
14
|
+
export * from './plugin.js';
|
|
15
|
+
export * from './positioning.js';
|
|
16
|
+
export * from './tokens.js';
|
|
17
|
+
export * from './utils.js';
|
|
18
|
+
export * from './virtual/document.js';
|
|
19
|
+
export * from './connection.js';
|
|
20
|
+
export * from './lsp.js';
|
|
21
|
+
export * from './lsp-protocol.js';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { LibroView } from '@difizen/libro-core';
|
|
2
|
+
import { LibroService } from '@difizen/libro-core';
|
|
3
|
+
import { ServerManager } from '@difizen/libro-kernel';
|
|
4
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
5
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
6
|
+
|
|
7
|
+
import { NotebookAdapter } from './adapters/notebook-adapter.js';
|
|
8
|
+
import {
|
|
9
|
+
ILSPCodeExtractorsManager,
|
|
10
|
+
ILSPDocumentConnectionManager,
|
|
11
|
+
ILSPFeatureManager,
|
|
12
|
+
} from './tokens.js';
|
|
13
|
+
|
|
14
|
+
@singleton({ contrib: [ApplicationContribution] })
|
|
15
|
+
export class LSPAppContribution implements ApplicationContribution {
|
|
16
|
+
@inject(LibroService) libroService: LibroService;
|
|
17
|
+
@inject(ServerManager) serverManager: ServerManager;
|
|
18
|
+
|
|
19
|
+
@inject(ILSPDocumentConnectionManager)
|
|
20
|
+
connectionManager: ILSPDocumentConnectionManager;
|
|
21
|
+
@inject(ILSPFeatureManager) featureManager: ILSPFeatureManager;
|
|
22
|
+
@inject(ILSPCodeExtractorsManager) codeExtractorManager: ILSPCodeExtractorsManager;
|
|
23
|
+
|
|
24
|
+
onStart() {
|
|
25
|
+
/**
|
|
26
|
+
* FIXME:capability声明应该和具体的实现写在一起
|
|
27
|
+
*/
|
|
28
|
+
this.featureManager.register({
|
|
29
|
+
id: 'libro-lsp',
|
|
30
|
+
capabilities: {
|
|
31
|
+
textDocument: {
|
|
32
|
+
completion: {
|
|
33
|
+
completionItem: { documentationFormat: ['markdown'] },
|
|
34
|
+
},
|
|
35
|
+
diagnostic: {
|
|
36
|
+
dynamicRegistration: true,
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* jedi-lsp的hover功能没有用hover的格式配置,而是使用completion的格式配置。。。
|
|
40
|
+
*/
|
|
41
|
+
hover: {
|
|
42
|
+
dynamicRegistration: true,
|
|
43
|
+
contentFormat: ['markdown', 'plaintext'],
|
|
44
|
+
},
|
|
45
|
+
signatureHelp: {
|
|
46
|
+
dynamicRegistration: true,
|
|
47
|
+
contextSupport: true,
|
|
48
|
+
signatureInformation: {
|
|
49
|
+
activeParameterSupport: true,
|
|
50
|
+
documentationFormat: ['markdown'],
|
|
51
|
+
parameterInformation: {
|
|
52
|
+
labelOffsetSupport: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
this.setupNotebookLanguageServer();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setupNotebookLanguageServer() {
|
|
63
|
+
this.libroService.onNotebookViewCreated(async (notebook) => {
|
|
64
|
+
this.activateNotebookLanguageServer(notebook);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Activate the language server for notebook.
|
|
70
|
+
*/
|
|
71
|
+
async activateNotebookLanguageServer(notebook: LibroView): Promise<void> {
|
|
72
|
+
await notebook.initialized;
|
|
73
|
+
await this.serverManager.ready;
|
|
74
|
+
|
|
75
|
+
const adapter = new NotebookAdapter(notebook, {
|
|
76
|
+
connectionManager: this.connectionManager,
|
|
77
|
+
featureManager: this.featureManager,
|
|
78
|
+
foreignCodeExtractorsManager: this.codeExtractorManager,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
this.connectionManager.registerAdapter(notebook.model.id, adapter);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LSPConnection } from './connection.js';
|
|
2
|
+
import type { Document } from './tokens.js';
|
|
3
|
+
import type { VirtualDocument } from './virtual/document.js';
|
|
4
|
+
|
|
5
|
+
export type LSPProviderResult = {
|
|
6
|
+
virtualDocument: VirtualDocument;
|
|
7
|
+
lspConnection: LSPConnection;
|
|
8
|
+
editor: Document.IEditor;
|
|
9
|
+
};
|
|
10
|
+
export type LSPProvider = () => Promise<LSPProviderResult>;
|
package/src/lsp.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import type * as lsp from 'vscode-languageserver-protocol';
|
|
5
|
+
|
|
6
|
+
export type ClientCapabilities = lsp.ClientCapabilities;
|
|
7
|
+
|
|
8
|
+
export enum DiagnosticSeverity {
|
|
9
|
+
Error = 1,
|
|
10
|
+
Warning = 2,
|
|
11
|
+
Information = 3,
|
|
12
|
+
Hint = 4,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum DiagnosticTag {
|
|
16
|
+
Unnecessary = 1,
|
|
17
|
+
Deprecated = 2,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum CompletionItemTag {
|
|
21
|
+
Deprecated = 1,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum CompletionItemKind {
|
|
25
|
+
Text = 1,
|
|
26
|
+
Method = 2,
|
|
27
|
+
Function = 3,
|
|
28
|
+
Constructor = 4,
|
|
29
|
+
Field = 5,
|
|
30
|
+
Variable = 6,
|
|
31
|
+
Class = 7,
|
|
32
|
+
Interface = 8,
|
|
33
|
+
Module = 9,
|
|
34
|
+
Property = 10,
|
|
35
|
+
Unit = 11,
|
|
36
|
+
Value = 12,
|
|
37
|
+
Enum = 13,
|
|
38
|
+
Keyword = 14,
|
|
39
|
+
Snippet = 15,
|
|
40
|
+
Color = 16,
|
|
41
|
+
File = 17,
|
|
42
|
+
Reference = 18,
|
|
43
|
+
Folder = 19,
|
|
44
|
+
EnumMember = 20,
|
|
45
|
+
Constant = 21,
|
|
46
|
+
Struct = 22,
|
|
47
|
+
Event = 23,
|
|
48
|
+
Operator = 24,
|
|
49
|
+
TypeParameter = 25,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export enum DocumentHighlightKind {
|
|
53
|
+
Text = 1,
|
|
54
|
+
Read = 2,
|
|
55
|
+
Write = 3,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export enum CompletionTriggerKind {
|
|
59
|
+
Invoked = 1,
|
|
60
|
+
TriggerCharacter = 2,
|
|
61
|
+
TriggerForIncompleteCompletions = 3,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export enum AdditionalCompletionTriggerKinds {
|
|
65
|
+
AutoInvoked = 9999,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type ExtendedCompletionTriggerKind =
|
|
69
|
+
| CompletionTriggerKind
|
|
70
|
+
| AdditionalCompletionTriggerKinds;
|
|
71
|
+
|
|
72
|
+
export type CompletionItemKindStrings = keyof typeof CompletionItemKind;
|
|
73
|
+
|
|
74
|
+
export type RecommendedLanguageIdentifier = keyof typeof Languages;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Language identifier for the LSP server, allowing any string but preferring
|
|
78
|
+
* the identifiers as recommended by the LSP documentation.
|
|
79
|
+
*/
|
|
80
|
+
export type LanguageIdentifier = RecommendedLanguageIdentifier | string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Type represents a location inside a resource, such as a line
|
|
84
|
+
* inside a text file.
|
|
85
|
+
*/
|
|
86
|
+
export type AnyLocation =
|
|
87
|
+
| lsp.Location
|
|
88
|
+
| lsp.Location[]
|
|
89
|
+
| lsp.LocationLink[]
|
|
90
|
+
| undefined
|
|
91
|
+
| null;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Type represents the completion result.
|
|
95
|
+
*/
|
|
96
|
+
export type AnyCompletion = lsp.CompletionList | lsp.CompletionItem[];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The language identifier for LSP, with the preferred identifier as defined in the documentation
|
|
100
|
+
* see the table in https://microsoft.github.io/language-server-protocol/specification#textDocumentItem
|
|
101
|
+
*/
|
|
102
|
+
export const Languages = {
|
|
103
|
+
'git-commit': 'Git (commit)',
|
|
104
|
+
'git-rebase': 'Git (rebase)',
|
|
105
|
+
'objective-c': 'Objective-C',
|
|
106
|
+
'objective-cpp': 'Objective-C++',
|
|
107
|
+
abap: 'ABAP',
|
|
108
|
+
bat: 'Windows Bat',
|
|
109
|
+
bibtex: 'BibTeX',
|
|
110
|
+
clojure: 'Clojure',
|
|
111
|
+
coffeescript: 'Coffeescript',
|
|
112
|
+
c: 'C',
|
|
113
|
+
cpp: 'C++',
|
|
114
|
+
csharp: 'C#',
|
|
115
|
+
css: 'CSS',
|
|
116
|
+
diff: 'Diff',
|
|
117
|
+
dart: 'Dart',
|
|
118
|
+
dockerfile: 'Dockerfile',
|
|
119
|
+
elixir: 'Elixir',
|
|
120
|
+
erlang: 'Erlang',
|
|
121
|
+
fsharp: 'F#',
|
|
122
|
+
go: 'Go',
|
|
123
|
+
groovy: 'Groovy',
|
|
124
|
+
handlebars: 'Handlebars',
|
|
125
|
+
html: 'HTML',
|
|
126
|
+
ini: 'Ini',
|
|
127
|
+
java: 'Java',
|
|
128
|
+
javascript: 'JavaScript',
|
|
129
|
+
javascriptreact: 'JavaScript React',
|
|
130
|
+
json: 'JSON',
|
|
131
|
+
latex: 'LaTeX',
|
|
132
|
+
less: 'Less',
|
|
133
|
+
lua: 'Lua',
|
|
134
|
+
makefile: 'Makefile',
|
|
135
|
+
markdown: 'Markdown',
|
|
136
|
+
perl: 'Perl',
|
|
137
|
+
perl6: 'Perl 6',
|
|
138
|
+
php: 'PHP',
|
|
139
|
+
powershell: 'Powershell',
|
|
140
|
+
jade: 'Pug',
|
|
141
|
+
python: 'Python',
|
|
142
|
+
r: 'R',
|
|
143
|
+
razor: 'Razor (cshtml)',
|
|
144
|
+
ruby: 'Ruby',
|
|
145
|
+
rust: 'Rust',
|
|
146
|
+
scss: 'SCSS (syntax using curly brackets)',
|
|
147
|
+
sass: 'SCSS (indented syntax)',
|
|
148
|
+
scala: 'Scala',
|
|
149
|
+
shaderlab: 'ShaderLab',
|
|
150
|
+
shellscript: 'Shell Script (Bash)',
|
|
151
|
+
sql: 'SQL',
|
|
152
|
+
swift: 'Swift',
|
|
153
|
+
typescript: 'TypeScript',
|
|
154
|
+
typescriptreact: 'TypeScript React',
|
|
155
|
+
tex: 'TeX',
|
|
156
|
+
vb: 'Visual Basic',
|
|
157
|
+
xml: 'XML',
|
|
158
|
+
xsl: 'XSL',
|
|
159
|
+
yaml: 'YAML',
|
|
160
|
+
};
|