-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: component and prop suggestions from remote API #43
base: main
Are you sure you want to change the base?
Conversation
This PR depends on nuxtlabs/monarch-mdc#12 to export a cjs build in order to consume the formatter from a single source of truth.
@farnabaz I have a working version of this I can demo. Happy to chat on the interface as well |
if (force && !componentMetadataURL) { | ||
const message = 'MDC component suggestions are not enabled. Please set mdc.componentMetadataURL in settings to configure your completion provider.' | ||
logger(message, true) | ||
vscode.window.showInformationMessage(message) | ||
return null | ||
} | ||
|
||
if (!componentMetadataURL) { | ||
return null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if, instead of fetching from API, we check for the existence of .nuxt/component-meta.mjs
file and read meta directly from this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the zero-config approach, but started a discussion here as to why I'm using an enhanced interface.
This looks great 🔥 If we read meta from And about the visual, what do you have in your mind? |
I agree that zero config would be ideal; however, for my use-case, especially for the block components, I want to supplement the metadata with a description of the component, along with a docs link as you can see here: Without providing this extra data, you can get component name completion, but there is no way to provide a "detail" or "description" of the component (the Since Thoughts? |
I see, how are you generating this Maybe we could find a solution to define these docs inside components and extract them in I don't mean to remote URL support, we can check the URL and as a fallback check the Later we'll see how to extract and extract documentation from component files |
I have a cached event handler in my Nitro server that essentially grabs the list of available components from
Originally I thought about using
Yes, I think the default |
The extension provides intelligent auto-completion for MDC components and their props when provided with a
mdc.componentMetadataURL
in your VS Code project's settings.Completions
Component Names
When typing a colon (
:
) at the start of a line, it suggests available component names.Component props
Within MDC component YAML frontmatter sections (between
---
), it provides contextual property suggestions with proper types and documentation.Configuration
Configure component suggestions by setting the
mdc.componentMetadataURL
in your VS Code settings.The URL can be your deployed site, or even a locally running server.
This URL should return JSON data that matches the following interface:
The extension caches component metadata for 6 hours and provides a command
MDC: Refresh Component Metadata
to manually update the cache.To customize the cache TTL you may customize the value for
mdc.componentMetadataCacheTTL
in settings. Defaults to360
minutes (6 hours).Notes
nuxt-component-meta
in a top-levelcomponent_meta
property to allow a custom endpoint to provide other contextual, top-level data for each component (e.g.description
). This does require a bit of an opinionated interface; however, would be easy to spin up with a project already utilizingnuxt-component-meta
(source).mdc.componentMetadataURL
property is not provided in a project's.vscode/settings.json
or globally, the extension will log but not error.