Home / Function/ getLanguagePlugin() — astro Function Reference

getLanguagePlugin() — astro Function Reference

Architecture documentation for the getLanguagePlugin() function in language.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  ef4cba51_c0fb_f47a_8028_3bb803c7dc38["getLanguagePlugin()"]
  6dfcea35_46db_2e95_f1a2_dd2af9c2da08["language.ts"]
  ef4cba51_c0fb_f47a_8028_3bb803c7dc38 -->|defined in| 6dfcea35_46db_2e95_f1a2_dd2af9c2da08
  style ef4cba51_c0fb_f47a_8028_3bb803c7dc38 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/ts-plugin/src/language.ts lines 12–39

export function getLanguagePlugin(): LanguagePlugin<string, AstroVirtualCode> {
	return {
		getLanguageId(fileName) {
			if (fileName.endsWith('.astro')) {
				return 'astro';
			}
		},
		createVirtualCode(fileName, languageId, snapshot) {
			if (languageId === 'astro') {
				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,
						};
					}
				}
			},
		},
	};
}

Domain

Subdomains

Frequently Asked Questions

What does getLanguagePlugin() do?
getLanguagePlugin() is a function in the astro codebase, defined in packages/language-tools/ts-plugin/src/language.ts.
Where is getLanguagePlugin() defined?
getLanguagePlugin() is defined in packages/language-tools/ts-plugin/src/language.ts at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free