@astrojs/language-server 1.0.4 → 2.0.0-next.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/LICENSE +3 -5
- package/bin/nodeServer.js +7 -3
- package/dist/core/astro2tsx.d.ts +6 -0
- package/dist/core/astro2tsx.js +119 -0
- package/dist/core/compilerUtils.d.ts +27 -0
- package/dist/core/compilerUtils.js +52 -0
- package/dist/core/index.d.ts +27 -0
- package/dist/core/index.js +119 -0
- package/dist/core/parseAstro.d.ts +27 -0
- package/dist/core/parseAstro.js +47 -0
- package/dist/core/parseCSS.d.ts +7 -0
- package/dist/core/parseCSS.js +116 -0
- package/dist/core/parseHTML.d.ts +7 -0
- package/dist/core/parseHTML.js +113 -0
- package/dist/core/parseJS.d.ts +7 -0
- package/dist/core/parseJS.js +236 -0
- package/dist/core/svelte.d.ts +18 -0
- package/dist/core/svelte.js +45 -0
- package/dist/core/utils.d.ts +14 -0
- package/dist/core/utils.js +138 -0
- package/dist/core/vue.d.ts +18 -0
- package/dist/core/vue.js +45 -0
- package/dist/importPackage.d.ts +1 -1
- package/dist/importPackage.js +4 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +26 -6
- package/dist/languageServerPlugin.d.ts +2 -0
- package/dist/languageServerPlugin.js +76 -0
- package/dist/nodeServer.js +6 -0
- package/dist/plugins/astro.d.ts +3 -0
- package/dist/plugins/astro.js +123 -0
- package/dist/plugins/{html/features/astro-attributes.js → html-data.js} +1 -0
- package/dist/plugins/html.d.ts +3 -0
- package/dist/plugins/html.js +33 -0
- package/dist/plugins/typescript/codeActions.d.ts +4 -0
- package/dist/plugins/typescript/codeActions.js +49 -0
- package/dist/plugins/typescript/completions.d.ts +3 -0
- package/dist/plugins/typescript/completions.js +81 -0
- package/dist/plugins/typescript/diagnostics.d.ts +12 -0
- package/dist/plugins/typescript/diagnostics.js +99 -0
- package/dist/plugins/typescript/index.d.ts +3 -0
- package/dist/plugins/typescript/index.js +57 -0
- package/dist/utils.d.ts +19 -69
- package/dist/utils.js +66 -239
- package/package.json +37 -38
- package/types/astro-jsx.d.ts +49 -5
- package/bin/browserServer.js +0 -3
- package/dist/browser.js +0 -15
- package/dist/check.d.ts +0 -23
- package/dist/check.js +0 -60
- package/dist/core/DiagnosticsManager.d.ts +0 -13
- package/dist/core/DiagnosticsManager.js +0 -29
- package/dist/core/config/ConfigManager.d.ts +0 -43
- package/dist/core/config/ConfigManager.js +0 -226
- package/dist/core/config/index.d.ts +0 -2
- package/dist/core/config/index.js +0 -18
- package/dist/core/config/interfaces.d.ts +0 -77
- package/dist/core/config/interfaces.js +0 -2
- package/dist/core/documents/AstroDocument.d.ts +0 -19
- package/dist/core/documents/AstroDocument.js +0 -43
- package/dist/core/documents/DocumentBase.d.ts +0 -68
- package/dist/core/documents/DocumentBase.js +0 -75
- package/dist/core/documents/DocumentManager.d.ts +0 -23
- package/dist/core/documents/DocumentManager.js +0 -100
- package/dist/core/documents/DocumentMapper.d.ts +0 -94
- package/dist/core/documents/DocumentMapper.js +0 -264
- package/dist/core/documents/index.d.ts +0 -5
- package/dist/core/documents/index.js +0 -21
- package/dist/core/documents/parseAstro.d.ts +0 -15
- package/dist/core/documents/parseAstro.js +0 -63
- package/dist/core/documents/parseHtml.d.ts +0 -13
- package/dist/core/documents/parseHtml.js +0 -126
- package/dist/core/documents/utils.d.ts +0 -63
- package/dist/core/documents/utils.js +0 -223
- package/dist/node.d.ts +0 -1
- package/dist/node.js +0 -43
- package/dist/plugins/PluginHost.d.ts +0 -42
- package/dist/plugins/PluginHost.js +0 -206
- package/dist/plugins/astro/AstroPlugin.d.ts +0 -17
- package/dist/plugins/astro/AstroPlugin.js +0 -90
- package/dist/plugins/astro/features/CompletionsProvider.d.ts +0 -17
- package/dist/plugins/astro/features/CompletionsProvider.js +0 -242
- package/dist/plugins/astro/features/DiagnosticsProvider.d.ts +0 -10
- package/dist/plugins/astro/features/DiagnosticsProvider.js +0 -23
- package/dist/plugins/css/CSSDocument.d.ts +0 -45
- package/dist/plugins/css/CSSDocument.js +0 -68
- package/dist/plugins/css/CSSPlugin.d.ts +0 -39
- package/dist/plugins/css/CSSPlugin.js +0 -274
- package/dist/plugins/css/StyleAttributeDocument.d.ts +0 -40
- package/dist/plugins/css/StyleAttributeDocument.js +0 -64
- package/dist/plugins/css/features/astro-selectors.d.ts +0 -2
- package/dist/plugins/css/features/astro-selectors.js +0 -15
- package/dist/plugins/css/features/getIdClassCompletions.d.ts +0 -19
- package/dist/plugins/css/features/getIdClassCompletions.js +0 -57
- package/dist/plugins/css/language-service.d.ts +0 -3
- package/dist/plugins/css/language-service.js +0 -47
- package/dist/plugins/html/HTMLPlugin.d.ts +0 -33
- package/dist/plugins/html/HTMLPlugin.js +0 -198
- package/dist/plugins/html/utils.d.ts +0 -6
- package/dist/plugins/html/utils.js +0 -11
- package/dist/plugins/index.d.ts +0 -6
- package/dist/plugins/index.js +0 -22
- package/dist/plugins/interfaces.d.ts +0 -101
- package/dist/plugins/interfaces.js +0 -2
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +0 -47
- package/dist/plugins/typescript/LanguageServiceManager.js +0 -97
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +0 -54
- package/dist/plugins/typescript/TypeScriptPlugin.js +0 -152
- package/dist/plugins/typescript/astro-sys.d.ts +0 -8
- package/dist/plugins/typescript/astro-sys.js +0 -46
- package/dist/plugins/typescript/astro2tsx.d.ts +0 -2
- package/dist/plugins/typescript/astro2tsx.js +0 -26
- package/dist/plugins/typescript/features/CodeActionsProvider.d.ts +0 -17
- package/dist/plugins/typescript/features/CodeActionsProvider.js +0 -212
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +0 -31
- package/dist/plugins/typescript/features/CompletionsProvider.js +0 -294
- package/dist/plugins/typescript/features/DefinitionsProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/DefinitionsProvider.js +0 -58
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +0 -25
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +0 -249
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.d.ts +0 -11
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +0 -67
- package/dist/plugins/typescript/features/FileReferencesProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/FileReferencesProvider.js +0 -27
- package/dist/plugins/typescript/features/FoldingRangesProvider.d.ts +0 -12
- package/dist/plugins/typescript/features/FoldingRangesProvider.js +0 -71
- package/dist/plugins/typescript/features/HoverProvider.d.ts +0 -10
- package/dist/plugins/typescript/features/HoverProvider.js +0 -50
- package/dist/plugins/typescript/features/ImplementationsProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/ImplementationsProvider.js +0 -53
- package/dist/plugins/typescript/features/InlayHintsProvider.d.ts +0 -13
- package/dist/plugins/typescript/features/InlayHintsProvider.js +0 -30
- package/dist/plugins/typescript/features/ReferencesProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/ReferencesProvider.js +0 -55
- package/dist/plugins/typescript/features/RenameProvider.d.ts +0 -13
- package/dist/plugins/typescript/features/RenameProvider.js +0 -60
- package/dist/plugins/typescript/features/SemanticTokenProvider.d.ts +0 -16
- package/dist/plugins/typescript/features/SemanticTokenProvider.js +0 -75
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +0 -22
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +0 -111
- package/dist/plugins/typescript/features/TypeDefinitionsProvider.d.ts +0 -9
- package/dist/plugins/typescript/features/TypeDefinitionsProvider.js +0 -54
- package/dist/plugins/typescript/features/utils.d.ts +0 -14
- package/dist/plugins/typescript/features/utils.js +0 -48
- package/dist/plugins/typescript/language-service.d.ts +0 -42
- package/dist/plugins/typescript/language-service.js +0 -277
- package/dist/plugins/typescript/module-loader.d.ts +0 -23
- package/dist/plugins/typescript/module-loader.js +0 -155
- package/dist/plugins/typescript/previewer.d.ts +0 -7
- package/dist/plugins/typescript/previewer.js +0 -108
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +0 -95
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +0 -187
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +0 -44
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +0 -179
- package/dist/plugins/typescript/snapshots/utils.d.ts +0 -29
- package/dist/plugins/typescript/snapshots/utils.js +0 -106
- package/dist/plugins/typescript/utils.d.ts +0 -75
- package/dist/plugins/typescript/utils.js +0 -366
- package/dist/server.d.ts +0 -6
- package/dist/server.js +0 -275
- package/types/README.md +0 -5
- /package/dist/{browser.d.ts → nodeServer.d.ts} +0 -0
- /package/dist/plugins/{html/features/astro-attributes.d.ts → html-data.d.ts} +0 -0
package/dist/check.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Diagnostic } from 'vscode-languageserver-types';
|
|
2
|
-
import { LSConfig } from './core/config';
|
|
3
|
-
export { DiagnosticSeverity } from 'vscode-languageserver-types';
|
|
4
|
-
export { Diagnostic };
|
|
5
|
-
export interface GetDiagnosticsResult {
|
|
6
|
-
fileUri: string;
|
|
7
|
-
text: string;
|
|
8
|
-
diagnostics: Diagnostic[];
|
|
9
|
-
}
|
|
10
|
-
export declare class AstroCheck {
|
|
11
|
-
private docManager;
|
|
12
|
-
private configManager;
|
|
13
|
-
private pluginHost;
|
|
14
|
-
constructor(workspacePath: string, typescriptPath: string, options?: LSConfig);
|
|
15
|
-
upsertDocument(doc: {
|
|
16
|
-
text: string;
|
|
17
|
-
uri: string;
|
|
18
|
-
}): void;
|
|
19
|
-
removeDocument(uri: string): void;
|
|
20
|
-
getDiagnostics(): Promise<GetDiagnosticsResult[]>;
|
|
21
|
-
private initialize;
|
|
22
|
-
private getDiagnosticsForFile;
|
|
23
|
-
}
|
package/dist/check.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AstroCheck = exports.DiagnosticSeverity = void 0;
|
|
4
|
-
const config_1 = require("./core/config");
|
|
5
|
-
const documents_1 = require("./core/documents");
|
|
6
|
-
const plugins_1 = require("./plugins");
|
|
7
|
-
const LanguageServiceManager_1 = require("./plugins/typescript/LanguageServiceManager");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
var vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
10
|
-
Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return vscode_languageserver_types_1.DiagnosticSeverity; } });
|
|
11
|
-
class AstroCheck {
|
|
12
|
-
constructor(workspacePath, typescriptPath, options) {
|
|
13
|
-
this.docManager = documents_1.DocumentManager.newInstance();
|
|
14
|
-
this.configManager = new config_1.ConfigManager();
|
|
15
|
-
this.pluginHost = new plugins_1.PluginHost(this.docManager);
|
|
16
|
-
try {
|
|
17
|
-
const ts = require(typescriptPath);
|
|
18
|
-
this.initialize(workspacePath, ts);
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
throw new Error(`Couldn't load TypeScript from path ${typescriptPath}`);
|
|
22
|
-
}
|
|
23
|
-
if (options) {
|
|
24
|
-
this.configManager.updateGlobalConfig(options);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
upsertDocument(doc) {
|
|
28
|
-
this.docManager.openDocument({
|
|
29
|
-
text: doc.text,
|
|
30
|
-
uri: doc.uri,
|
|
31
|
-
});
|
|
32
|
-
this.docManager.markAsOpenedInClient(doc.uri);
|
|
33
|
-
}
|
|
34
|
-
removeDocument(uri) {
|
|
35
|
-
if (!this.docManager.get(uri)) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this.docManager.closeDocument(uri);
|
|
39
|
-
this.docManager.releaseDocument(uri);
|
|
40
|
-
}
|
|
41
|
-
async getDiagnostics() {
|
|
42
|
-
return await Promise.all(this.docManager.getAllOpenedByClient().map(async (doc) => {
|
|
43
|
-
const uri = doc[1].uri;
|
|
44
|
-
return await this.getDiagnosticsForFile(uri);
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
initialize(workspacePath, ts) {
|
|
48
|
-
const languageServiceManager = new LanguageServiceManager_1.LanguageServiceManager(this.docManager, [(0, utils_1.normalizeUri)(workspacePath)], this.configManager, ts);
|
|
49
|
-
this.pluginHost.registerPlugin(new plugins_1.TypeScriptPlugin(this.configManager, languageServiceManager));
|
|
50
|
-
}
|
|
51
|
-
async getDiagnosticsForFile(uri) {
|
|
52
|
-
const diagnostics = await this.pluginHost.getDiagnostics({ uri });
|
|
53
|
-
return {
|
|
54
|
-
fileUri: uri || '',
|
|
55
|
-
text: this.docManager.get(uri)?.getText() || '',
|
|
56
|
-
diagnostics,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.AstroCheck = AstroCheck;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Connection, Diagnostic, TextDocumentIdentifier } from 'vscode-languageserver';
|
|
2
|
-
import type { AstroDocument, DocumentManager } from './documents';
|
|
3
|
-
export type SendDiagnostics = Connection['sendDiagnostics'];
|
|
4
|
-
export type GetDiagnostics = (doc: TextDocumentIdentifier) => Thenable<Diagnostic[]>;
|
|
5
|
-
export declare class DiagnosticsManager {
|
|
6
|
-
private sendDiagnostics;
|
|
7
|
-
private docManager;
|
|
8
|
-
private getDiagnostics;
|
|
9
|
-
constructor(sendDiagnostics: SendDiagnostics, docManager: DocumentManager, getDiagnostics: GetDiagnostics);
|
|
10
|
-
updateAll(): void;
|
|
11
|
-
update(document: AstroDocument): Promise<void>;
|
|
12
|
-
removeDiagnostics(document: AstroDocument): void;
|
|
13
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiagnosticsManager = void 0;
|
|
4
|
-
class DiagnosticsManager {
|
|
5
|
-
constructor(sendDiagnostics, docManager, getDiagnostics) {
|
|
6
|
-
this.sendDiagnostics = sendDiagnostics;
|
|
7
|
-
this.docManager = docManager;
|
|
8
|
-
this.getDiagnostics = getDiagnostics;
|
|
9
|
-
}
|
|
10
|
-
updateAll() {
|
|
11
|
-
this.docManager.getAllOpenedByClient().forEach((doc) => {
|
|
12
|
-
this.update(doc[1]);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async update(document) {
|
|
16
|
-
const diagnostics = await this.getDiagnostics({ uri: document.getURL() });
|
|
17
|
-
this.sendDiagnostics({
|
|
18
|
-
uri: document.getURL(),
|
|
19
|
-
diagnostics,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
removeDiagnostics(document) {
|
|
23
|
-
this.sendDiagnostics({
|
|
24
|
-
uri: document.getURL(),
|
|
25
|
-
diagnostics: [],
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.DiagnosticsManager = DiagnosticsManager;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { VSCodeEmmetConfig } from '@vscode/emmet-helper';
|
|
2
|
-
import type { FormatCodeSettings, UserPreferences } from 'typescript';
|
|
3
|
-
import type { Connection, FormattingOptions } from 'vscode-languageserver';
|
|
4
|
-
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
-
import type { LSConfig, LSCSSConfig, LSHTMLConfig, LSTypescriptConfig } from './interfaces';
|
|
6
|
-
export declare const defaultLSConfig: LSConfig;
|
|
7
|
-
type DeepPartial<T> = T extends Record<string, unknown> ? {
|
|
8
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
9
|
-
} : T;
|
|
10
|
-
/**
|
|
11
|
-
* Manager class to facilitate accessing and updating the user's config
|
|
12
|
-
* Not to be confused with other kind of configurations (such as the Astro project configuration and the TypeScript/Javascript one)
|
|
13
|
-
* For more info on this, see the [internal docs](../../../../../docs/internal/language-server/config.md)
|
|
14
|
-
*/
|
|
15
|
-
export declare class ConfigManager {
|
|
16
|
-
private connection?;
|
|
17
|
-
private hasConfigurationCapability?;
|
|
18
|
-
private globalConfig;
|
|
19
|
-
private documentSettings;
|
|
20
|
-
shouldRefreshTSServices: boolean;
|
|
21
|
-
private isTrusted;
|
|
22
|
-
constructor(connection?: Connection | undefined, hasConfigurationCapability?: boolean | undefined);
|
|
23
|
-
updateConfig(): void;
|
|
24
|
-
removeDocument(scopeUri: string): void;
|
|
25
|
-
getConfig<T>(section: string, scopeUri: string): Promise<T | Record<string, any>>;
|
|
26
|
-
getEmmetConfig(document: TextDocument): Promise<VSCodeEmmetConfig>;
|
|
27
|
-
getPrettierVSConfig(document: TextDocument): Promise<Record<string, any>>;
|
|
28
|
-
getTSFormatConfig(document: TextDocument, vscodeOptions?: FormattingOptions): Promise<FormatCodeSettings>;
|
|
29
|
-
getTSPreferences(document: TextDocument): Promise<UserPreferences>;
|
|
30
|
-
/**
|
|
31
|
-
* Return true if a plugin and an optional feature is enabled
|
|
32
|
-
*/
|
|
33
|
-
isEnabled(document: TextDocument, plugin: keyof LSConfig, feature?: keyof LSTypescriptConfig | keyof LSCSSConfig | keyof LSHTMLConfig): Promise<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Updating the global config should only be done in cases where the client doesn't support `workspace/configuration`
|
|
36
|
-
* or inside of tests.
|
|
37
|
-
*
|
|
38
|
-
* The `outsideAstro` parameter can be set to true to change configurations in the global scope.
|
|
39
|
-
* For example, to change TypeScript settings
|
|
40
|
-
*/
|
|
41
|
-
updateGlobalConfig(config: DeepPartial<LSConfig> | any, outsideAstro?: boolean): void;
|
|
42
|
-
}
|
|
43
|
-
export {};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfigManager = exports.defaultLSConfig = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
// The default language server configuration is used only in two cases:
|
|
6
|
-
// 1. When the client does not support `workspace/configuration` requests and as such, needs a global config
|
|
7
|
-
// 2. Inside tests, where we don't have a client connection because.. well.. we don't have a client
|
|
8
|
-
// Additionally, the default config is used to set default settings for some settings (ex: formatting settings)
|
|
9
|
-
exports.defaultLSConfig = {
|
|
10
|
-
typescript: {
|
|
11
|
-
enabled: true,
|
|
12
|
-
allowArbitraryAttributes: false,
|
|
13
|
-
diagnostics: { enabled: true },
|
|
14
|
-
hover: { enabled: true },
|
|
15
|
-
completions: { enabled: true },
|
|
16
|
-
definitions: { enabled: true },
|
|
17
|
-
documentSymbols: { enabled: true },
|
|
18
|
-
codeActions: { enabled: true },
|
|
19
|
-
rename: { enabled: true },
|
|
20
|
-
signatureHelp: { enabled: true },
|
|
21
|
-
semanticTokens: { enabled: true },
|
|
22
|
-
},
|
|
23
|
-
css: {
|
|
24
|
-
enabled: true,
|
|
25
|
-
hover: { enabled: true },
|
|
26
|
-
completions: { enabled: true, emmet: true },
|
|
27
|
-
documentColors: { enabled: true },
|
|
28
|
-
documentSymbols: { enabled: true },
|
|
29
|
-
},
|
|
30
|
-
html: {
|
|
31
|
-
enabled: true,
|
|
32
|
-
hover: { enabled: true },
|
|
33
|
-
completions: { enabled: true, emmet: true },
|
|
34
|
-
tagComplete: { enabled: true },
|
|
35
|
-
documentSymbols: { enabled: true },
|
|
36
|
-
},
|
|
37
|
-
format: {
|
|
38
|
-
indentFrontmatter: false,
|
|
39
|
-
newLineAfterFrontmatter: true,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Manager class to facilitate accessing and updating the user's config
|
|
44
|
-
* Not to be confused with other kind of configurations (such as the Astro project configuration and the TypeScript/Javascript one)
|
|
45
|
-
* For more info on this, see the [internal docs](../../../../../docs/internal/language-server/config.md)
|
|
46
|
-
*/
|
|
47
|
-
class ConfigManager {
|
|
48
|
-
constructor(connection, hasConfigurationCapability) {
|
|
49
|
-
this.connection = connection;
|
|
50
|
-
this.hasConfigurationCapability = hasConfigurationCapability;
|
|
51
|
-
this.globalConfig = { astro: exports.defaultLSConfig };
|
|
52
|
-
this.documentSettings = {};
|
|
53
|
-
// If set to true, the next time we need a TypeScript language service, we'll rebuild it so it gets the new config
|
|
54
|
-
this.shouldRefreshTSServices = false;
|
|
55
|
-
this.isTrusted = true;
|
|
56
|
-
}
|
|
57
|
-
updateConfig() {
|
|
58
|
-
// Reset all cached document settings
|
|
59
|
-
this.documentSettings = {};
|
|
60
|
-
this.shouldRefreshTSServices = true;
|
|
61
|
-
}
|
|
62
|
-
removeDocument(scopeUri) {
|
|
63
|
-
delete this.documentSettings[scopeUri];
|
|
64
|
-
}
|
|
65
|
-
async getConfig(section, scopeUri) {
|
|
66
|
-
if (!this.connection || !this.hasConfigurationCapability) {
|
|
67
|
-
return (0, utils_1.get)(this.globalConfig, section) ?? {};
|
|
68
|
-
}
|
|
69
|
-
if (!this.documentSettings[scopeUri]) {
|
|
70
|
-
this.documentSettings[scopeUri] = {};
|
|
71
|
-
}
|
|
72
|
-
if (!this.documentSettings[scopeUri][section]) {
|
|
73
|
-
this.documentSettings[scopeUri][section] = await this.connection.workspace.getConfiguration({
|
|
74
|
-
scopeUri,
|
|
75
|
-
section,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return this.documentSettings[scopeUri][section];
|
|
79
|
-
}
|
|
80
|
-
async getEmmetConfig(document) {
|
|
81
|
-
const emmetConfig = (await this.getConfig('emmet', document.uri)) ?? {};
|
|
82
|
-
return {
|
|
83
|
-
...emmetConfig,
|
|
84
|
-
preferences: emmetConfig.preferences ?? {},
|
|
85
|
-
showExpandedAbbreviation: emmetConfig.showExpandedAbbreviation ?? 'always',
|
|
86
|
-
showAbbreviationSuggestions: emmetConfig.showAbbreviationSuggestions ?? true,
|
|
87
|
-
syntaxProfiles: emmetConfig.syntaxProfiles ?? {},
|
|
88
|
-
variables: emmetConfig.variables ?? {},
|
|
89
|
-
excludeLanguages: emmetConfig.excludeLanguages ?? [],
|
|
90
|
-
showSuggestionsAsSnippets: emmetConfig.showSuggestionsAsSnippets ?? false,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
async getPrettierVSConfig(document) {
|
|
94
|
-
const prettierVSConfig = (await this.getConfig('prettier', document.uri)) ?? {};
|
|
95
|
-
return prettierVSConfig;
|
|
96
|
-
}
|
|
97
|
-
async getTSFormatConfig(document, vscodeOptions) {
|
|
98
|
-
const formatConfig = (await this.getConfig('typescript.format', document.uri)) ?? {};
|
|
99
|
-
return {
|
|
100
|
-
tabSize: vscodeOptions?.tabSize,
|
|
101
|
-
indentSize: vscodeOptions?.tabSize,
|
|
102
|
-
convertTabsToSpaces: vscodeOptions?.insertSpaces,
|
|
103
|
-
// We can use \n here since the editor normalizes later on to its line endings.
|
|
104
|
-
newLineCharacter: '\n',
|
|
105
|
-
insertSpaceAfterCommaDelimiter: formatConfig.insertSpaceAfterCommaDelimiter ?? true,
|
|
106
|
-
insertSpaceAfterConstructor: formatConfig.insertSpaceAfterConstructor ?? false,
|
|
107
|
-
insertSpaceAfterSemicolonInForStatements: formatConfig.insertSpaceAfterSemicolonInForStatements ?? true,
|
|
108
|
-
insertSpaceBeforeAndAfterBinaryOperators: formatConfig.insertSpaceBeforeAndAfterBinaryOperators ?? true,
|
|
109
|
-
insertSpaceAfterKeywordsInControlFlowStatements: formatConfig.insertSpaceAfterKeywordsInControlFlowStatements ?? true,
|
|
110
|
-
insertSpaceAfterFunctionKeywordForAnonymousFunctions: formatConfig.insertSpaceAfterFunctionKeywordForAnonymousFunctions ?? true,
|
|
111
|
-
insertSpaceBeforeFunctionParenthesis: formatConfig.insertSpaceBeforeFunctionParenthesis ?? false,
|
|
112
|
-
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: formatConfig.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis ?? false,
|
|
113
|
-
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: formatConfig.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets ?? false,
|
|
114
|
-
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: formatConfig.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces ?? true,
|
|
115
|
-
insertSpaceAfterOpeningAndBeforeClosingEmptyBraces: formatConfig.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces ?? true,
|
|
116
|
-
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: formatConfig.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces ?? false,
|
|
117
|
-
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: formatConfig.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces ?? false,
|
|
118
|
-
insertSpaceAfterTypeAssertion: formatConfig.insertSpaceAfterTypeAssertion ?? false,
|
|
119
|
-
placeOpenBraceOnNewLineForFunctions: formatConfig.placeOpenBraceOnNewLineForFunctions ?? false,
|
|
120
|
-
placeOpenBraceOnNewLineForControlBlocks: formatConfig.placeOpenBraceOnNewLineForControlBlocks ?? false,
|
|
121
|
-
semicolons: formatConfig.semicolons ?? 'ignore',
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
async getTSPreferences(document) {
|
|
125
|
-
const config = (await this.getConfig('typescript', document.uri)) ?? {};
|
|
126
|
-
const preferences = (await this.getConfig('typescript.preferences', document.uri)) ?? {};
|
|
127
|
-
return {
|
|
128
|
-
quotePreference: getQuoteStylePreference(preferences),
|
|
129
|
-
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferences),
|
|
130
|
-
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferences),
|
|
131
|
-
allowTextChangesInNewFiles: document.uri.startsWith('file://'),
|
|
132
|
-
providePrefixAndSuffixTextForRename: (preferences.renameShorthandProperties ?? true) === false ? false : preferences.useAliasesForRenames ?? true,
|
|
133
|
-
includeAutomaticOptionalChainCompletions: config.suggest?.includeAutomaticOptionalChainCompletions ?? true,
|
|
134
|
-
includeCompletionsForImportStatements: config.suggest?.includeCompletionsForImportStatements ?? true,
|
|
135
|
-
includeCompletionsWithSnippetText: config.suggest?.includeCompletionsWithSnippetText ?? true,
|
|
136
|
-
includeCompletionsForModuleExports: config.suggest?.autoImports ?? true,
|
|
137
|
-
allowIncompleteCompletions: true,
|
|
138
|
-
includeCompletionsWithInsertText: true,
|
|
139
|
-
// Inlay Hints
|
|
140
|
-
includeInlayParameterNameHints: getInlayParameterNameHintsPreference(config),
|
|
141
|
-
includeInlayParameterNameHintsWhenArgumentMatchesName: !(config.inlayHints?.parameterNames?.suppressWhenArgumentMatchesName ?? true),
|
|
142
|
-
includeInlayFunctionParameterTypeHints: config.inlayHints?.parameterTypes?.enabled ?? false,
|
|
143
|
-
includeInlayVariableTypeHints: config.inlayHints?.variableTypes?.enabled ?? false,
|
|
144
|
-
includeInlayPropertyDeclarationTypeHints: config.inlayHints?.propertyDeclarationTypes?.enabled ?? false,
|
|
145
|
-
includeInlayFunctionLikeReturnTypeHints: config.inlayHints?.functionLikeReturnTypes?.enabled ?? false,
|
|
146
|
-
includeInlayEnumMemberValueHints: config.inlayHints?.enumMemberValues?.enabled ?? false,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Return true if a plugin and an optional feature is enabled
|
|
151
|
-
*/
|
|
152
|
-
async isEnabled(document, plugin, feature) {
|
|
153
|
-
const config = (await this.getConfig('astro', document.uri)) ?? {};
|
|
154
|
-
if (config[plugin]) {
|
|
155
|
-
let res = config[plugin].enabled ?? true;
|
|
156
|
-
if (feature && config[plugin][feature]) {
|
|
157
|
-
res = (res && config[plugin][feature].enabled) ?? true;
|
|
158
|
-
}
|
|
159
|
-
return res;
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Updating the global config should only be done in cases where the client doesn't support `workspace/configuration`
|
|
165
|
-
* or inside of tests.
|
|
166
|
-
*
|
|
167
|
-
* The `outsideAstro` parameter can be set to true to change configurations in the global scope.
|
|
168
|
-
* For example, to change TypeScript settings
|
|
169
|
-
*/
|
|
170
|
-
updateGlobalConfig(config, outsideAstro) {
|
|
171
|
-
if (outsideAstro) {
|
|
172
|
-
this.globalConfig = (0, utils_1.mergeDeep)({}, this.globalConfig, config);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
this.globalConfig.astro = (0, utils_1.mergeDeep)({}, exports.defaultLSConfig, this.globalConfig.astro, config);
|
|
176
|
-
}
|
|
177
|
-
this.shouldRefreshTSServices = true;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
exports.ConfigManager = ConfigManager;
|
|
181
|
-
function getQuoteStylePreference(config) {
|
|
182
|
-
switch (config.quoteStyle) {
|
|
183
|
-
case 'single':
|
|
184
|
-
return 'single';
|
|
185
|
-
case 'double':
|
|
186
|
-
return 'double';
|
|
187
|
-
default:
|
|
188
|
-
return 'auto';
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function getImportModuleSpecifierPreference(config) {
|
|
192
|
-
switch (config.importModuleSpecifier) {
|
|
193
|
-
case 'project-relative':
|
|
194
|
-
return 'project-relative';
|
|
195
|
-
case 'relative':
|
|
196
|
-
return 'relative';
|
|
197
|
-
case 'non-relative':
|
|
198
|
-
return 'non-relative';
|
|
199
|
-
default:
|
|
200
|
-
return undefined;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function getImportModuleSpecifierEndingPreference(config) {
|
|
204
|
-
switch (config.importModuleSpecifierEnding) {
|
|
205
|
-
case 'minimal':
|
|
206
|
-
return 'minimal';
|
|
207
|
-
case 'index':
|
|
208
|
-
return 'index';
|
|
209
|
-
case 'js':
|
|
210
|
-
return 'js';
|
|
211
|
-
default:
|
|
212
|
-
return 'auto';
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function getInlayParameterNameHintsPreference(config) {
|
|
216
|
-
switch (config.inlayHints?.parameterNames?.enabled) {
|
|
217
|
-
case 'none':
|
|
218
|
-
return 'none';
|
|
219
|
-
case 'literals':
|
|
220
|
-
return 'literals';
|
|
221
|
-
case 'all':
|
|
222
|
-
return 'all';
|
|
223
|
-
default:
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ConfigManager"), exports);
|
|
18
|
-
__exportStar(require("./interfaces"), exports);
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
typescript?: LSTypescriptConfig;
|
|
7
|
-
html?: LSHTMLConfig;
|
|
8
|
-
css?: LSCSSConfig;
|
|
9
|
-
format?: LSFormatConfig;
|
|
10
|
-
}
|
|
11
|
-
export interface LSFormatConfig {
|
|
12
|
-
indentFrontmatter?: boolean;
|
|
13
|
-
newLineAfterFrontmatter?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface LSTypescriptConfig {
|
|
16
|
-
enabled?: boolean;
|
|
17
|
-
allowArbitraryAttributes?: boolean;
|
|
18
|
-
diagnostics?: {
|
|
19
|
-
enabled?: boolean;
|
|
20
|
-
};
|
|
21
|
-
hover?: {
|
|
22
|
-
enabled?: boolean;
|
|
23
|
-
};
|
|
24
|
-
documentSymbols?: {
|
|
25
|
-
enabled?: boolean;
|
|
26
|
-
};
|
|
27
|
-
completions?: {
|
|
28
|
-
enabled?: boolean;
|
|
29
|
-
};
|
|
30
|
-
definitions?: {
|
|
31
|
-
enabled?: boolean;
|
|
32
|
-
};
|
|
33
|
-
codeActions?: {
|
|
34
|
-
enabled?: boolean;
|
|
35
|
-
};
|
|
36
|
-
rename?: {
|
|
37
|
-
enabled?: boolean;
|
|
38
|
-
};
|
|
39
|
-
signatureHelp?: {
|
|
40
|
-
enabled?: boolean;
|
|
41
|
-
};
|
|
42
|
-
semanticTokens?: {
|
|
43
|
-
enabled?: boolean;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export interface LSHTMLConfig {
|
|
47
|
-
enabled?: boolean;
|
|
48
|
-
hover?: {
|
|
49
|
-
enabled?: boolean;
|
|
50
|
-
};
|
|
51
|
-
completions?: {
|
|
52
|
-
enabled?: boolean;
|
|
53
|
-
emmet?: boolean;
|
|
54
|
-
};
|
|
55
|
-
tagComplete?: {
|
|
56
|
-
enabled?: boolean;
|
|
57
|
-
};
|
|
58
|
-
documentSymbols?: {
|
|
59
|
-
enabled?: boolean;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export interface LSCSSConfig {
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
hover?: {
|
|
65
|
-
enabled?: boolean;
|
|
66
|
-
};
|
|
67
|
-
completions?: {
|
|
68
|
-
enabled?: boolean;
|
|
69
|
-
emmet?: boolean;
|
|
70
|
-
};
|
|
71
|
-
documentColors?: {
|
|
72
|
-
enabled?: boolean;
|
|
73
|
-
};
|
|
74
|
-
documentSymbols?: {
|
|
75
|
-
enabled?: boolean;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { HTMLDocument, Range } 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
|
-
scriptTags: TagInformation[];
|
|
13
|
-
constructor(url: string, content: string);
|
|
14
|
-
private updateDocInfo;
|
|
15
|
-
setText(text: string): void;
|
|
16
|
-
getText(range?: Range | undefined): string;
|
|
17
|
-
getURL(): string;
|
|
18
|
-
getFilePath(): string | null;
|
|
19
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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, this.astroMeta);
|
|
20
|
-
this.styleTags = (0, utils_2.extractStyleTags)(this.content, this.html);
|
|
21
|
-
this.scriptTags = (0, utils_2.extractScriptTags)(this.content, this.html);
|
|
22
|
-
}
|
|
23
|
-
setText(text) {
|
|
24
|
-
this.content = text;
|
|
25
|
-
this.version++;
|
|
26
|
-
this.updateDocInfo();
|
|
27
|
-
}
|
|
28
|
-
getText(range) {
|
|
29
|
-
if (range) {
|
|
30
|
-
const start = this.offsetAt(range.start);
|
|
31
|
-
const end = this.offsetAt(range.end);
|
|
32
|
-
return this.content.substring(start, end);
|
|
33
|
-
}
|
|
34
|
-
return this.content;
|
|
35
|
-
}
|
|
36
|
-
getURL() {
|
|
37
|
-
return this.url;
|
|
38
|
-
}
|
|
39
|
-
getFilePath() {
|
|
40
|
-
return (0, utils_1.urlToPath)(this.url);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.AstroDocument = AstroDocument;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Position } from 'vscode-languageserver';
|
|
2
|
-
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a textual document.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class ReadableDocument implements TextDocument {
|
|
7
|
-
/**
|
|
8
|
-
* Get the text content of the document
|
|
9
|
-
*/
|
|
10
|
-
abstract getText(): string;
|
|
11
|
-
/**
|
|
12
|
-
* Returns the url of the document
|
|
13
|
-
*/
|
|
14
|
-
abstract getURL(): string;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the file path if the url scheme is file
|
|
17
|
-
*/
|
|
18
|
-
abstract getFilePath(): string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Current version of the document.
|
|
21
|
-
*/
|
|
22
|
-
version: number;
|
|
23
|
-
/**
|
|
24
|
-
* Should be cleared when there's an update to the text
|
|
25
|
-
*/
|
|
26
|
-
protected lineOffsets?: number[];
|
|
27
|
-
/**
|
|
28
|
-
* Get the length of the document's content
|
|
29
|
-
*/
|
|
30
|
-
getTextLength(): number;
|
|
31
|
-
/**
|
|
32
|
-
* Get the line and character based on the offset
|
|
33
|
-
* @param offset The index of the position
|
|
34
|
-
*/
|
|
35
|
-
positionAt(offset: number): Position;
|
|
36
|
-
/**
|
|
37
|
-
* Get the index of the line and character position
|
|
38
|
-
* @param position Line and character position
|
|
39
|
-
*/
|
|
40
|
-
offsetAt(position: Position): number;
|
|
41
|
-
getLineUntilOffset(offset: number): string;
|
|
42
|
-
private getLineOffsets;
|
|
43
|
-
/**
|
|
44
|
-
* Implements TextDocument
|
|
45
|
-
*/
|
|
46
|
-
get uri(): string;
|
|
47
|
-
get lines(): string[];
|
|
48
|
-
get lineCount(): number;
|
|
49
|
-
abstract languageId: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Represents a textual document that can be manipulated.
|
|
53
|
-
*/
|
|
54
|
-
export declare abstract class WritableDocument extends ReadableDocument {
|
|
55
|
-
/**
|
|
56
|
-
* Set the text content of the document.
|
|
57
|
-
* Implementers should set `lineOffsets` to `undefined` here.
|
|
58
|
-
* @param text The new text content
|
|
59
|
-
*/
|
|
60
|
-
abstract setText(text: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* Update the text between two positions.
|
|
63
|
-
* @param text The new text slice
|
|
64
|
-
* @param start Start offset of the new text
|
|
65
|
-
* @param end End offset of the new text
|
|
66
|
-
*/
|
|
67
|
-
update(text: string, start: number, end: number): void;
|
|
68
|
-
}
|