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
Allow formatting unreleased languages #1747
Comments
If you you'd like to add Handlebars to the list of the supported languages, I wonder if you could not change prettier-vscode/src/LanguageResolver.ts Line 72 in d4505c8
to
|
@dcyriller That is what I wrote in alternatives :) |
On this same note, it would be nice to pass in an array of file extensions that Prettier should parse. For example, I've setup my local "overrides": [
{
"files": "*.edge",
"options": {
"parser": "html"
}
}
] However, despite including the extension in the As usual, you can set a For now, I've just modified the method within the installed extension, in-place: getSupportedFileExtensions(e){
const t=[];
return (this.getSupportLanguages(e).forEach((e=> {
e&&e.extensions&&t.push(...e.extensions)
})),t.filter(((e,t,r)=>r.indexOf(e)===t))).concat('.edge');
} Sure, it'll get over-written on an update, but it serves the purpose for now. |
Closing this. It is possible to do this today :) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is your feature request related to a problem? Please describe.
The Handlebars language is currently unreleased in Prettier (https://github.com/prettier/prettier/blob/main/src/language-handlebars/index.js). Because of this Prettier-VSCode doesn't currently format
hbs
files.The Ember.js community created this extension for using Prettier to format Handlebars: https://github.com/mfeckie/handlebars-formatter
This extension hardcodes the Prettier version it supports and doesn't use the installed version in the project. Personally I wanted to use a different version of Prettier, so I forked the extension and released my own: https://github.com/ember-tooling/prettier-for-handlebars-vscode/
The issue with this is that this still hardcodes the version. Yesterday I played around with the notion of adding support to Pretter-VSCode for Handlebars and the outcome works, without too many changes.
You can see the changes I made here: main...ember-tooling:main
Describe the solution you'd like
I would like Pretter-VSCode to add a new configuration which allows passing in a
prettier.SupportLanguage
object that will be added to the supportedLanguages for the extension.Describe alternatives you've considered
Another option is to add a configuration for allowing
getSupportLanguage
to also returnunreleased
languages. The issue with this is that from what I understand this would require a change to Prettier itself as the exportedgetSupportInfo
function from Prettier doesn't accept arguments. https://github.com/prettier/prettier/blob/main/src/index.js#L62Finally, if none of these are approved I can go ahead and release a new version of my extension Prettier For Handlebars VSCode with the new code from https://github.com/ember-tooling/prettier-vscode but this seems like a waste of maintaining effort and having support built into the official extension will allow much easier access to users.
Additional context
Open to chat about this :)
Thanks!
The text was updated successfully, but these errors were encountered: