Home / Function/ getAstroLanguagePlugin() — astro Function Reference

getAstroLanguagePlugin() — astro Function Reference

Architecture documentation for the getAstroLanguagePlugin() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  913138c4_e025_35d6_132e_69f7c2d85305["getAstroLanguagePlugin()"]
  3d0a8903_cb4c_d139_320b_9571e3568661["index.ts"]
  913138c4_e025_35d6_132e_69f7c2d85305 -->|defined in| 3d0a8903_cb4c_d139_320b_9571e3568661
  74ca29f0_8866_5b66_9220_9e25385641a6["getLanguagePlugins()"]
  74ca29f0_8866_5b66_9220_9e25385641a6 -->|calls| 913138c4_e025_35d6_132e_69f7c2d85305
  style 913138c4_e025_35d6_132e_69f7c2d85305 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/src/core/index.ts lines 94–141

export function getAstroLanguagePlugin(): LanguagePlugin<URI, AstroVirtualCode> {
	return {
		getLanguageId(uri) {
			if (uri.path.endsWith('.astro')) {
				return 'astro';
			}
		},
		createVirtualCode(uri, languageId, snapshot) {
			if (languageId === 'astro') {
				const fileName = uri.fsPath.replace(/\\/g, '/');
				return new AstroVirtualCode(fileName, snapshot);
			}
		},
		typescript: {
			extraFileExtensions: [{ extension: 'astro', isMixedContent: true, scriptKind: 7 }],
			getServiceScript(astroCode) {
				for (const code of forEachEmbeddedCode(astroCode)) {
					if (code.id === 'tsx') {
						return {
							code,
							extension: '.tsx',
							scriptKind: 4 satisfies ts.ScriptKind.TSX,
						};
					}
				}
				return undefined;
			},
			getExtraServiceScripts(fileName, astroCode) {
				const result: TypeScriptExtraServiceScript[] = [];
				for (const code of forEachEmbeddedCode(astroCode)) {
					if (code.id.endsWith('.mjs') || code.id.endsWith('.mts')) {
						const fileExtension = code.id.endsWith('.mjs') ? '.mjs' : '.mts';
						result.push({
							fileName: fileName + '.' + code.id,
							code,
							extension: fileExtension,
							scriptKind:
								fileExtension === '.mjs'
									? (1 satisfies ts.ScriptKind.JS)
									: (3 satisfies ts.ScriptKind.TS),
						});
					}
				}
				return result;
			},
		},
	};
}

Domain

Subdomains

Frequently Asked Questions

What does getAstroLanguagePlugin() do?
getAstroLanguagePlugin() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/index.ts.
Where is getAstroLanguagePlugin() defined?
getAstroLanguagePlugin() is defined in packages/language-tools/language-server/src/core/index.ts at line 94.
What calls getAstroLanguagePlugin()?
getAstroLanguagePlugin() is called by 1 function(s): getLanguagePlugins.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free