@astrojs/language-server 0.11.0 → 0.12.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/CHANGELOG.md +6 -0
- package/bin/browserServer.js +3 -0
- package/bin/nodeServer.js +3 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +8 -0
- package/dist/check.js +2 -5
- package/dist/core/DiagnosticsManager.d.ts +3 -3
- package/dist/core/DiagnosticsManager.js +2 -2
- package/dist/core/config/ConfigManager.d.ts +19 -164
- package/dist/core/config/ConfigManager.js +62 -101
- package/dist/core/config/index.d.ts +1 -0
- package/dist/core/config/index.js +1 -0
- package/dist/core/config/interfaces.d.ts +123 -0
- package/dist/core/config/interfaces.js +2 -0
- package/dist/core/documents/AstroDocument.d.ts +18 -0
- package/dist/core/documents/AstroDocument.js +37 -0
- package/dist/core/documents/DocumentBase.d.ts +10 -2
- package/dist/core/documents/DocumentBase.js +15 -50
- package/dist/core/documents/DocumentManager.d.ts +12 -16
- package/dist/core/documents/DocumentManager.js +32 -26
- package/dist/core/documents/DocumentMapper.js +3 -1
- package/dist/core/documents/index.d.ts +1 -1
- package/dist/core/documents/index.js +1 -1
- package/dist/core/documents/parseAstro.d.ts +2 -2
- package/dist/core/documents/parseHtml.d.ts +2 -2
- package/dist/core/documents/parseHtml.js +4 -1
- package/dist/core/documents/utils.d.ts +22 -26
- package/dist/core/documents/utils.js +96 -134
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/node.d.ts +1 -0
- package/dist/node.js +29 -0
- package/dist/plugins/PluginHost.d.ts +8 -9
- package/dist/plugins/PluginHost.js +22 -36
- package/dist/plugins/astro/AstroPlugin.d.ts +11 -12
- package/dist/plugins/astro/AstroPlugin.js +17 -42
- package/dist/plugins/astro/features/{CompletionProvider.d.ts → CompletionsProvider.d.ts} +5 -5
- package/dist/plugins/astro/features/{CompletionProvider.js → CompletionsProvider.js} +33 -58
- package/dist/plugins/css/CSSDocument.d.ts +3 -3
- package/dist/plugins/css/CSSDocument.js +7 -16
- package/dist/plugins/css/CSSPlugin.d.ts +19 -11
- package/dist/plugins/css/CSSPlugin.js +63 -41
- package/dist/plugins/css/StyleAttributeDocument.d.ts +2 -2
- package/dist/plugins/css/StyleAttributeDocument.js +2 -2
- package/dist/plugins/css/features/astro-selectors.d.ts +2 -0
- package/dist/plugins/css/features/astro-selectors.js +16 -0
- package/dist/plugins/css/features/{getIdClassCompletion.d.ts → getIdClassCompletions.d.ts} +3 -3
- package/dist/plugins/css/features/{getIdClassCompletion.js → getIdClassCompletions.js} +10 -9
- package/dist/plugins/css/{service.d.ts → language-service.d.ts} +0 -0
- package/dist/plugins/css/{service.js → language-service.js} +2 -1
- package/dist/plugins/html/HTMLPlugin.d.ts +15 -17
- package/dist/plugins/html/HTMLPlugin.js +33 -41
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/interfaces.d.ts +35 -48
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +33 -14
- package/dist/plugins/typescript/LanguageServiceManager.js +57 -32
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +16 -23
- package/dist/plugins/typescript/TypeScriptPlugin.js +43 -55
- package/dist/plugins/typescript/astro-sys.d.ts +5 -3
- package/dist/plugins/typescript/astro-sys.js +24 -45
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +6 -6
- package/dist/plugins/typescript/features/CompletionsProvider.js +17 -37
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +4 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +22 -61
- package/dist/plugins/typescript/features/HoverProvider.d.ts +4 -5
- package/dist/plugins/typescript/features/HoverProvider.js +9 -10
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +4 -5
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +15 -11
- package/dist/plugins/typescript/features/utils.d.ts +1 -12
- package/dist/plugins/typescript/features/utils.js +2 -22
- package/dist/plugins/typescript/language-service.d.ts +38 -0
- package/dist/plugins/typescript/language-service.js +227 -0
- package/dist/plugins/typescript/module-loader.d.ts +5 -8
- package/dist/plugins/typescript/module-loader.js +43 -23
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +90 -0
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +135 -0
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +42 -0
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +197 -0
- package/dist/plugins/typescript/snapshots/utils.d.ts +28 -0
- package/dist/plugins/typescript/snapshots/utils.js +84 -0
- package/dist/plugins/typescript/utils.d.ts +8 -12
- package/dist/plugins/typescript/utils.js +105 -158
- package/dist/server.d.ts +2 -4
- package/dist/server.js +88 -54
- package/dist/utils.d.ts +16 -8
- package/dist/utils.js +29 -14
- package/package.json +18 -12
- package/bin/server.js +0 -7
- package/dist/core/documents/Document.d.ts +0 -51
- package/dist/core/documents/Document.js +0 -135
- package/dist/plugins/typescript/DocumentSnapshot.d.ts +0 -99
- package/dist/plugins/typescript/DocumentSnapshot.js +0 -259
- package/dist/plugins/typescript/SnapshotManager.d.ts +0 -24
- package/dist/plugins/typescript/SnapshotManager.js +0 -103
- package/dist/plugins/typescript/languageService.d.ts +0 -17
- package/dist/plugins/typescript/languageService.js +0 -173
- package/types/index.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const browser_1 = require("vscode-languageserver/browser");
|
|
4
|
+
const server_1 = require("./server");
|
|
5
|
+
const messageReader = new browser_1.BrowserMessageReader(self);
|
|
6
|
+
const messageWriter = new browser_1.BrowserMessageWriter(self);
|
|
7
|
+
const connection = (0, browser_1.createConnection)(messageReader, messageWriter);
|
|
8
|
+
(0, server_1.startLanguageServer)(connection);
|
package/dist/check.js
CHANGED
|
@@ -15,11 +15,8 @@ class AstroCheck {
|
|
|
15
15
|
}
|
|
16
16
|
upsertDocument(doc) {
|
|
17
17
|
this.docManager.openDocument({
|
|
18
|
-
languageId: 'astro',
|
|
19
|
-
version: 0,
|
|
20
18
|
text: doc.text,
|
|
21
19
|
uri: doc.uri,
|
|
22
|
-
overrideText: true
|
|
23
20
|
});
|
|
24
21
|
this.docManager.markAsOpenedInClient(doc.uri);
|
|
25
22
|
}
|
|
@@ -37,7 +34,7 @@ class AstroCheck {
|
|
|
37
34
|
}));
|
|
38
35
|
}
|
|
39
36
|
initialize(workspacePath) {
|
|
40
|
-
this.pluginHost.
|
|
37
|
+
this.pluginHost.registerPlugin(new plugins_1.TypeScriptPlugin(this.docManager, this.configManager, [workspacePath]));
|
|
41
38
|
}
|
|
42
39
|
async getDiagnosticsForFile(uri) {
|
|
43
40
|
var _a;
|
|
@@ -45,7 +42,7 @@ class AstroCheck {
|
|
|
45
42
|
return {
|
|
46
43
|
filePath: new URL(uri).pathname || '',
|
|
47
44
|
text: ((_a = this.docManager.get(uri)) === null || _a === void 0 ? void 0 : _a.getText()) || '',
|
|
48
|
-
diagnostics
|
|
45
|
+
diagnostics,
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection, TextDocumentIdentifier, Diagnostic } from 'vscode-languageserver';
|
|
2
|
-
import { DocumentManager,
|
|
2
|
+
import { DocumentManager, AstroDocument } from './documents';
|
|
3
3
|
export declare type SendDiagnostics = Connection['sendDiagnostics'];
|
|
4
4
|
export declare type GetDiagnostics = (doc: TextDocumentIdentifier) => Thenable<Diagnostic[]>;
|
|
5
5
|
export declare class DiagnosticsManager {
|
|
@@ -8,6 +8,6 @@ export declare class DiagnosticsManager {
|
|
|
8
8
|
private getDiagnostics;
|
|
9
9
|
constructor(sendDiagnostics: SendDiagnostics, docManager: DocumentManager, getDiagnostics: GetDiagnostics);
|
|
10
10
|
updateAll(): void;
|
|
11
|
-
update(document:
|
|
12
|
-
removeDiagnostics(document:
|
|
11
|
+
update(document: AstroDocument): Promise<void>;
|
|
12
|
+
removeDiagnostics(document: AstroDocument): void;
|
|
13
13
|
}
|
|
@@ -16,13 +16,13 @@ class DiagnosticsManager {
|
|
|
16
16
|
const diagnostics = await this.getDiagnostics({ uri: document.getURL() });
|
|
17
17
|
this.sendDiagnostics({
|
|
18
18
|
uri: document.getURL(),
|
|
19
|
-
diagnostics
|
|
19
|
+
diagnostics,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
removeDiagnostics(document) {
|
|
23
23
|
this.sendDiagnostics({
|
|
24
24
|
uri: document.getURL(),
|
|
25
|
-
diagnostics: []
|
|
25
|
+
diagnostics: [],
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,178 +1,33 @@
|
|
|
1
1
|
import { VSCodeEmmetConfig } from '@vscode/emmet-helper';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
* Representation of the language server config.
|
|
5
|
-
*/
|
|
6
|
-
export interface LSConfig {
|
|
7
|
-
typescript: LSTypescriptConfig;
|
|
8
|
-
css: LSCSSConfig;
|
|
9
|
-
html: LSHTMLConfig;
|
|
10
|
-
astro: LSAstroConfig;
|
|
11
|
-
}
|
|
12
|
-
export interface LSTypescriptConfig {
|
|
13
|
-
enable: boolean;
|
|
14
|
-
diagnostics: {
|
|
15
|
-
enable: boolean;
|
|
16
|
-
};
|
|
17
|
-
hover: {
|
|
18
|
-
enable: boolean;
|
|
19
|
-
};
|
|
20
|
-
documentSymbols: {
|
|
21
|
-
enable: boolean;
|
|
22
|
-
};
|
|
23
|
-
completions: {
|
|
24
|
-
enable: boolean;
|
|
25
|
-
};
|
|
26
|
-
findReferences: {
|
|
27
|
-
enable: boolean;
|
|
28
|
-
};
|
|
29
|
-
definitions: {
|
|
30
|
-
enable: boolean;
|
|
31
|
-
};
|
|
32
|
-
codeActions: {
|
|
33
|
-
enable: boolean;
|
|
34
|
-
};
|
|
35
|
-
rename: {
|
|
36
|
-
enable: boolean;
|
|
37
|
-
};
|
|
38
|
-
selectionRange: {
|
|
39
|
-
enable: boolean;
|
|
40
|
-
};
|
|
41
|
-
signatureHelp: {
|
|
42
|
-
enable: boolean;
|
|
43
|
-
};
|
|
44
|
-
semanticTokens: {
|
|
45
|
-
enable: boolean;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export interface LSCSSConfig {
|
|
49
|
-
enable: boolean;
|
|
50
|
-
globals: string;
|
|
51
|
-
diagnostics: {
|
|
52
|
-
enable: boolean;
|
|
53
|
-
};
|
|
54
|
-
hover: {
|
|
55
|
-
enable: boolean;
|
|
56
|
-
};
|
|
57
|
-
completions: {
|
|
58
|
-
enable: boolean;
|
|
59
|
-
emmet: boolean;
|
|
60
|
-
};
|
|
61
|
-
documentColors: {
|
|
62
|
-
enable: boolean;
|
|
63
|
-
};
|
|
64
|
-
colorPresentations: {
|
|
65
|
-
enable: boolean;
|
|
66
|
-
};
|
|
67
|
-
documentSymbols: {
|
|
68
|
-
enable: boolean;
|
|
69
|
-
};
|
|
70
|
-
selectionRange: {
|
|
71
|
-
enable: boolean;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export interface LSHTMLConfig {
|
|
75
|
-
enable: boolean;
|
|
76
|
-
hover: {
|
|
77
|
-
enable: boolean;
|
|
78
|
-
};
|
|
79
|
-
completions: {
|
|
80
|
-
enable: boolean;
|
|
81
|
-
emmet: boolean;
|
|
82
|
-
};
|
|
83
|
-
tagComplete: {
|
|
84
|
-
enable: boolean;
|
|
85
|
-
};
|
|
86
|
-
documentSymbols: {
|
|
87
|
-
enable: boolean;
|
|
88
|
-
};
|
|
89
|
-
renameTags: {
|
|
90
|
-
enable: boolean;
|
|
91
|
-
};
|
|
92
|
-
linkedEditing: {
|
|
93
|
-
enable: boolean;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
export declare type CompilerWarningsSettings = Record<string, 'ignore' | 'error'>;
|
|
97
|
-
export interface LSAstroConfig {
|
|
98
|
-
enable: boolean;
|
|
99
|
-
compilerWarnings: CompilerWarningsSettings;
|
|
100
|
-
diagnostics: {
|
|
101
|
-
enable: boolean;
|
|
102
|
-
};
|
|
103
|
-
format: {
|
|
104
|
-
enable: boolean;
|
|
105
|
-
};
|
|
106
|
-
rename: {
|
|
107
|
-
enable: boolean;
|
|
108
|
-
};
|
|
109
|
-
completions: {
|
|
110
|
-
enable: boolean;
|
|
111
|
-
};
|
|
112
|
-
hover: {
|
|
113
|
-
enable: boolean;
|
|
114
|
-
};
|
|
115
|
-
codeActions: {
|
|
116
|
-
enable: boolean;
|
|
117
|
-
};
|
|
118
|
-
selectionRange: {
|
|
119
|
-
enable: boolean;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
export declare type TsUserConfigLang = 'typescript' | 'javascript';
|
|
123
|
-
declare type DeepPartial<T> = T extends CompilerWarningsSettings ? T : {
|
|
2
|
+
import { LSConfig } from './interfaces';
|
|
3
|
+
declare type DeepPartial<T> = T extends Record<string, unknown> ? {
|
|
124
4
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* A subset of the JS/TS VS Code settings which
|
|
128
|
-
* are transformed to ts.UserPreferences.
|
|
129
|
-
* It may not be available in other IDEs, that's why the keys are optional.
|
|
130
|
-
*/
|
|
131
|
-
export interface TSUserConfig {
|
|
132
|
-
preferences?: TsUserPreferencesConfig;
|
|
133
|
-
suggest?: TSSuggestConfig;
|
|
134
|
-
}
|
|
5
|
+
} : T;
|
|
135
6
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
7
|
+
* Manager class to facilitate accessing and updating the user's config
|
|
8
|
+
* Not to be confused with other kind of configurations (such as the Astro project configuration and the TypeScript/Javascript one)
|
|
9
|
+
* For more info on this, see the [internal docs](../../../../../docs/internal/language-server/config.md)
|
|
138
10
|
*/
|
|
139
|
-
export interface TsUserPreferencesConfig {
|
|
140
|
-
importModuleSpecifier: UserPreferences['importModuleSpecifierPreference'];
|
|
141
|
-
quoteStyle: UserPreferences['quotePreference'];
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* A subset of the JS/TS VS Code settings which
|
|
145
|
-
* are transformed to ts.UserPreferences.
|
|
146
|
-
*/
|
|
147
|
-
export interface TSSuggestConfig {
|
|
148
|
-
includeAutomaticOptionalChainCompletions: boolean | undefined;
|
|
149
|
-
}
|
|
150
11
|
export declare class ConfigManager {
|
|
151
12
|
private config;
|
|
152
|
-
private listeners;
|
|
153
13
|
private emmetConfig;
|
|
154
|
-
private
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
update(config: DeepPartial<LSConfig>): void;
|
|
14
|
+
private isTrusted;
|
|
15
|
+
updateConfig(config: DeepPartial<LSConfig>): void;
|
|
16
|
+
updateEmmetConfig(config: VSCodeEmmetConfig): void;
|
|
17
|
+
getEmmetConfig(): VSCodeEmmetConfig;
|
|
159
18
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
19
|
+
* Whether or not specified setting is enabled
|
|
20
|
+
* @param key a string which is a path. Example: 'astro.diagnostics.enabled'.
|
|
21
|
+
*/
|
|
163
22
|
enabled(key: string): boolean;
|
|
164
23
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
24
|
+
* Get a specific setting value
|
|
25
|
+
* @param key a string which is a path. Example: 'astro.diagnostics.enable'.
|
|
26
|
+
*/
|
|
168
27
|
get<T>(key: string): T;
|
|
169
28
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
updateEmmetConfig(config: VSCodeEmmetConfig): void;
|
|
174
|
-
updateTsJsUserPreferences(config: Record<TsUserConfigLang, TSUserConfig>): void;
|
|
175
|
-
private _updateTsUserPreferences;
|
|
176
|
-
getEmmetConfig(): VSCodeEmmetConfig;
|
|
29
|
+
* Get the entire user configuration
|
|
30
|
+
*/
|
|
31
|
+
getFullConfig(): Readonly<LSConfig>;
|
|
177
32
|
}
|
|
178
33
|
export {};
|
|
@@ -2,134 +2,95 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfigManager = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
/**
|
|
6
|
-
* Default config for the language server.
|
|
7
|
-
*/
|
|
8
5
|
const defaultLSConfig = {
|
|
6
|
+
astro: {
|
|
7
|
+
enabled: true,
|
|
8
|
+
diagnostics: { enabled: true },
|
|
9
|
+
rename: { enabled: true },
|
|
10
|
+
format: { enabled: true },
|
|
11
|
+
completions: { enabled: true },
|
|
12
|
+
hover: { enabled: true },
|
|
13
|
+
codeActions: { enabled: true },
|
|
14
|
+
selectionRange: { enabled: true },
|
|
15
|
+
},
|
|
9
16
|
typescript: {
|
|
10
|
-
|
|
11
|
-
diagnostics: {
|
|
12
|
-
hover: {
|
|
13
|
-
completions: {
|
|
14
|
-
definitions: {
|
|
15
|
-
findReferences: {
|
|
16
|
-
documentSymbols: {
|
|
17
|
-
codeActions: {
|
|
18
|
-
rename: {
|
|
19
|
-
selectionRange: {
|
|
20
|
-
signatureHelp: {
|
|
21
|
-
semanticTokens: {
|
|
17
|
+
enabled: true,
|
|
18
|
+
diagnostics: { enabled: true },
|
|
19
|
+
hover: { enabled: true },
|
|
20
|
+
completions: { enabled: true },
|
|
21
|
+
definitions: { enabled: true },
|
|
22
|
+
findReferences: { enabled: true },
|
|
23
|
+
documentSymbols: { enabled: true },
|
|
24
|
+
codeActions: { enabled: true },
|
|
25
|
+
rename: { enabled: true },
|
|
26
|
+
selectionRange: { enabled: true },
|
|
27
|
+
signatureHelp: { enabled: true },
|
|
28
|
+
semanticTokens: { enabled: true },
|
|
29
|
+
implementation: { enabled: true },
|
|
30
|
+
typeDefinition: { enabled: true },
|
|
22
31
|
},
|
|
23
32
|
css: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
selectionRange: { enable: true }
|
|
33
|
+
enabled: true,
|
|
34
|
+
diagnostics: { enabled: true },
|
|
35
|
+
hover: { enabled: true },
|
|
36
|
+
completions: { enabled: true, emmet: true },
|
|
37
|
+
documentColors: { enabled: true },
|
|
38
|
+
colorPresentations: { enabled: true },
|
|
39
|
+
documentSymbols: { enabled: true },
|
|
40
|
+
selectionRange: { enabled: true },
|
|
33
41
|
},
|
|
34
42
|
html: {
|
|
35
|
-
|
|
36
|
-
hover: {
|
|
37
|
-
completions: {
|
|
38
|
-
tagComplete: {
|
|
39
|
-
documentSymbols: {
|
|
40
|
-
renameTags: {
|
|
41
|
-
linkedEditing: {
|
|
43
|
+
enabled: true,
|
|
44
|
+
hover: { enabled: true },
|
|
45
|
+
completions: { enabled: true, emmet: true },
|
|
46
|
+
tagComplete: { enabled: true },
|
|
47
|
+
documentSymbols: { enabled: true },
|
|
48
|
+
renameTags: { enabled: true },
|
|
49
|
+
linkedEditing: { enabled: true },
|
|
42
50
|
},
|
|
43
|
-
astro: {
|
|
44
|
-
enable: true,
|
|
45
|
-
compilerWarnings: {},
|
|
46
|
-
diagnostics: { enable: true },
|
|
47
|
-
rename: { enable: true },
|
|
48
|
-
format: {
|
|
49
|
-
enable: true
|
|
50
|
-
},
|
|
51
|
-
completions: { enable: true },
|
|
52
|
-
hover: { enable: true },
|
|
53
|
-
codeActions: { enable: true },
|
|
54
|
-
selectionRange: { enable: true }
|
|
55
|
-
}
|
|
56
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Manager class to facilitate accessing and updating the user's config
|
|
54
|
+
* Not to be confused with other kind of configurations (such as the Astro project configuration and the TypeScript/Javascript one)
|
|
55
|
+
* For more info on this, see the [internal docs](../../../../../docs/internal/language-server/config.md)
|
|
56
|
+
*/
|
|
57
57
|
class ConfigManager {
|
|
58
58
|
constructor() {
|
|
59
59
|
this.config = defaultLSConfig;
|
|
60
|
-
this.listeners = [];
|
|
61
60
|
this.emmetConfig = {};
|
|
62
|
-
this.
|
|
63
|
-
typescript: {
|
|
64
|
-
includeCompletionsForImportStatements: true,
|
|
65
|
-
includeCompletionsWithInsertText: true,
|
|
66
|
-
includeAutomaticOptionalChainCompletions: true
|
|
67
|
-
},
|
|
68
|
-
javascript: {
|
|
69
|
-
includeCompletionsForImportStatements: true,
|
|
70
|
-
includeCompletionsWithInsertText: true,
|
|
71
|
-
includeAutomaticOptionalChainCompletions: true
|
|
72
|
-
}
|
|
73
|
-
};
|
|
61
|
+
this.isTrusted = true;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
|
-
* Updates config.
|
|
77
|
-
*/
|
|
78
|
-
update(config) {
|
|
79
|
-
var _a;
|
|
63
|
+
updateConfig(config) {
|
|
80
64
|
// Ideally we shouldn't need the merge here because all updates should be valid and complete configs.
|
|
81
65
|
// But since those configs come from the client they might be out of synch with the valid config:
|
|
82
66
|
// We might at some point in the future forget to synch config settings in all packages after updating the config.
|
|
83
67
|
this.config = (0, lodash_1.merge)({}, defaultLSConfig, this.config, config);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this.
|
|
68
|
+
}
|
|
69
|
+
updateEmmetConfig(config) {
|
|
70
|
+
this.emmetConfig = config || {};
|
|
71
|
+
}
|
|
72
|
+
getEmmetConfig() {
|
|
73
|
+
return this.emmetConfig;
|
|
90
74
|
}
|
|
91
75
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
* Whether or not specified setting is enabled
|
|
77
|
+
* @param key a string which is a path. Example: 'astro.diagnostics.enabled'.
|
|
78
|
+
*/
|
|
95
79
|
enabled(key) {
|
|
96
80
|
return !!this.get(key);
|
|
97
81
|
}
|
|
98
82
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
* Get a specific setting value
|
|
84
|
+
* @param key a string which is a path. Example: 'astro.diagnostics.enable'.
|
|
85
|
+
*/
|
|
102
86
|
get(key) {
|
|
103
87
|
return (0, lodash_1.get)(this.config, key);
|
|
104
88
|
}
|
|
105
89
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
}
|
|
111
|
-
updateEmmetConfig(config) {
|
|
112
|
-
this.emmetConfig = config || {};
|
|
113
|
-
}
|
|
114
|
-
updateTsJsUserPreferences(config) {
|
|
115
|
-
['typescript', 'javascript'].forEach((lang) => {
|
|
116
|
-
if (config[lang]) {
|
|
117
|
-
this._updateTsUserPreferences(lang, config[lang]);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
_updateTsUserPreferences(lang, config) {
|
|
122
|
-
var _a, _b, _c, _d;
|
|
123
|
-
this.tsUserPreferences[lang] = {
|
|
124
|
-
...this.tsUserPreferences[lang],
|
|
125
|
-
importModuleSpecifierPreference: (_a = config.preferences) === null || _a === void 0 ? void 0 : _a.importModuleSpecifier,
|
|
126
|
-
quotePreference: (_b = config.preferences) === null || _b === void 0 ? void 0 : _b.quoteStyle,
|
|
127
|
-
includeAutomaticOptionalChainCompletions: (_d = (_c = config.suggest) === null || _c === void 0 ? void 0 : _c.includeAutomaticOptionalChainCompletions) !== null && _d !== void 0 ? _d : true,
|
|
128
|
-
includeCompletionsWithInsertText: true
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
getEmmetConfig() {
|
|
132
|
-
return this.emmetConfig;
|
|
90
|
+
* Get the entire user configuration
|
|
91
|
+
*/
|
|
92
|
+
getFullConfig() {
|
|
93
|
+
return this.config;
|
|
133
94
|
}
|
|
134
95
|
}
|
|
135
96
|
exports.ConfigManager = ConfigManager;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Representation of the language server config.
|
|
3
|
+
* Make sure that this is kept in sync with the `package.json` of the VS Code extension
|
|
4
|
+
*/
|
|
5
|
+
export interface LSConfig {
|
|
6
|
+
astro: LSAstroConfig;
|
|
7
|
+
typescript: LSTypescriptConfig;
|
|
8
|
+
html: LSHTMLConfig;
|
|
9
|
+
css: LSCSSConfig;
|
|
10
|
+
}
|
|
11
|
+
export interface LSAstroConfig {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
diagnostics: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
};
|
|
16
|
+
format: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
};
|
|
19
|
+
rename: {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
};
|
|
22
|
+
completions: {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
};
|
|
25
|
+
hover: {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
};
|
|
28
|
+
codeActions: {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
};
|
|
31
|
+
selectionRange: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface LSTypescriptConfig {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
diagnostics: {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
};
|
|
40
|
+
hover: {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
};
|
|
43
|
+
documentSymbols: {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
};
|
|
46
|
+
completions: {
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
};
|
|
49
|
+
findReferences: {
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
};
|
|
52
|
+
definitions: {
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
};
|
|
55
|
+
codeActions: {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
};
|
|
58
|
+
rename: {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
};
|
|
61
|
+
selectionRange: {
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
};
|
|
64
|
+
signatureHelp: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
};
|
|
67
|
+
semanticTokens: {
|
|
68
|
+
enabled: boolean;
|
|
69
|
+
};
|
|
70
|
+
implementation: {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
};
|
|
73
|
+
typeDefinition: {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export interface LSHTMLConfig {
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
hover: {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
};
|
|
82
|
+
completions: {
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
emmet: boolean;
|
|
85
|
+
};
|
|
86
|
+
tagComplete: {
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
};
|
|
89
|
+
documentSymbols: {
|
|
90
|
+
enabled: boolean;
|
|
91
|
+
};
|
|
92
|
+
renameTags: {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
};
|
|
95
|
+
linkedEditing: {
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export interface LSCSSConfig {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
diagnostics: {
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
hover: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
};
|
|
107
|
+
completions: {
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
emmet: boolean;
|
|
110
|
+
};
|
|
111
|
+
documentColors: {
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
};
|
|
114
|
+
colorPresentations: {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
};
|
|
117
|
+
documentSymbols: {
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
};
|
|
120
|
+
selectionRange: {
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTMLDocument } from 'vscode-html-languageservice';
|
|
2
|
+
import { WritableDocument } from './DocumentBase';
|
|
3
|
+
import { AstroMetadata } from './parseAstro';
|
|
4
|
+
import { TagInformation } from './utils';
|
|
5
|
+
export declare class AstroDocument extends WritableDocument {
|
|
6
|
+
url: string;
|
|
7
|
+
content: string;
|
|
8
|
+
languageId: string;
|
|
9
|
+
astroMeta: AstroMetadata;
|
|
10
|
+
html: HTMLDocument;
|
|
11
|
+
styleTags: TagInformation[];
|
|
12
|
+
constructor(url: string, content: string);
|
|
13
|
+
private updateDocInfo;
|
|
14
|
+
setText(text: string): void;
|
|
15
|
+
getText(): string;
|
|
16
|
+
getURL(): string;
|
|
17
|
+
getFilePath(): string | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AstroDocument = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const DocumentBase_1 = require("./DocumentBase");
|
|
6
|
+
const parseAstro_1 = require("./parseAstro");
|
|
7
|
+
const parseHtml_1 = require("./parseHtml");
|
|
8
|
+
const utils_2 = require("./utils");
|
|
9
|
+
class AstroDocument extends DocumentBase_1.WritableDocument {
|
|
10
|
+
constructor(url, content) {
|
|
11
|
+
super();
|
|
12
|
+
this.url = url;
|
|
13
|
+
this.content = content;
|
|
14
|
+
this.languageId = 'astro';
|
|
15
|
+
this.updateDocInfo();
|
|
16
|
+
}
|
|
17
|
+
updateDocInfo() {
|
|
18
|
+
this.astroMeta = (0, parseAstro_1.parseAstro)(this.content);
|
|
19
|
+
this.html = (0, parseHtml_1.parseHtml)(this.content);
|
|
20
|
+
this.styleTags = (0, utils_2.extractStyleTags)(this.content, this.html);
|
|
21
|
+
}
|
|
22
|
+
setText(text) {
|
|
23
|
+
this.content = text;
|
|
24
|
+
this.version++;
|
|
25
|
+
this.updateDocInfo();
|
|
26
|
+
}
|
|
27
|
+
getText() {
|
|
28
|
+
return this.content;
|
|
29
|
+
}
|
|
30
|
+
getURL() {
|
|
31
|
+
return this.url;
|
|
32
|
+
}
|
|
33
|
+
getFilePath() {
|
|
34
|
+
return (0, utils_1.urlToPath)(this.url);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.AstroDocument = AstroDocument;
|