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
Add mongo to supported languages #1009
Conversation
TSX test fails 😞 it seems unrelated : can someone help me?
|
I have tested running the extension together with Azure Cosmos DB and it works 🎉 my .mongo file is formated, and I can execute my mongo command. |
Can someone indicate me if I need to add a test for .mongo files? I assume I need to create an "ugly" file inside of |
This would be a change for the Prettier library itself rather than the VS Code extension for prettier. Please open an issue at https://github.com/prettier/prettier. Specifically, you would need to add a new supported language to prettier that tells prettier that a mongodb file should use the json parser. |
I'm a bit lost at what would need to be changed in the prettier codebase, and I'm not sure why you are mentioning JSON. A mongo file looks like this : db.users.find({ someField: { $exists: true } }); I have found one issue in prettier mentioning .mongo files, and I understand @vjeux wants to support mongo queries, since they use the javascript language. I think mongo files are not a different language that prettier needs to support, but simply a different file extension that needs to be recognised as containing valid javascript. Correct me if I'm wrong, but it seems to me this is the responsibility of the vs code extension to define a formatter on .mongo files ? |
I did open an issue as you suggested 👍 |
My PR to the prettier codebase has been merged prettier/prettier#6848 Would you consider reopening this PR? @ntotten |
I guess rangeSupportedLanguages means it's a hardcoded list of languages for which formatting of ranges is supported. Why doesn't Prettier itself provide this information I wonder? Anyways, this change doesn't seem to be essential for your use case @aymericbouzy. |
You are right @thorn0 the change in the prettier codebase is enough. Thanks! |
CHANGELOG.md
with a summary of your changesThe Mongo Language has JS Syntax but is not formatted by Prettier. Changing language mode to "JS" for .mongo files works for formatting, but then the command to run the query against the DB is not available. It would make working with MongoDB inside of VS Code much easier !