create() — astro Function Reference
Architecture documentation for the create() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 40de1046_3db4_9e9e_888e_d0239f84f2a0["create()"] 6294fa88_eb1f_7295_351b_f03f29337b81["index.ts"] 40de1046_3db4_9e9e_888e_d0239f84f2a0 -->|defined in| 6294fa88_eb1f_7295_351b_f03f29337b81 style 40de1046_3db4_9e9e_888e_d0239f84f2a0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/plugins/typescript-addons/index.ts lines 11–59
export const create = (): LanguageServicePlugin => {
return {
capabilities: {
completionProvider: {
resolveProvider: true,
},
},
create(context): LanguageServicePluginInstance {
return {
isAdditionalCompletion: true,
// Q: Why the empty transform and resolve functions?
// A: Volar will skip mapping the completion items if those functions are defined, as such we can return the snippets
// completions as-is, this is notably useful for snippets that insert to the frontmatter, since we don't need to map anything.
transformCompletionItem(item) {
return item;
},
provideCompletionItems(document, position, completionContext, token) {
if (
!context ||
!isJSDocument ||
token.isCancellationRequested ||
completionContext.triggerKind === 2
)
return null;
const decoded = context.decodeEmbeddedDocumentUri(URI.parse(document.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
const root = sourceScript?.generated?.root;
if (!(root instanceof AstroVirtualCode)) return undefined;
if (!isInsideFrontmatter(document.offsetAt(position), root.astroMeta.frontmatter))
return null;
const completionList: CompletionList = {
items: [],
isIncomplete: false,
};
completionList.items.push(...getSnippetCompletions(root.astroMeta.frontmatter));
return completionList;
},
resolveCompletionItem(item) {
return item;
},
};
},
};
};
Domain
Subdomains
Source
Frequently Asked Questions
What does create() do?
create() is a function in the astro codebase, defined in packages/language-tools/language-server/src/plugins/typescript-addons/index.ts.
Where is create() defined?
create() is defined in packages/language-tools/language-server/src/plugins/typescript-addons/index.ts at line 11.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free