How to format on save with devcontainer
I'd like to automatically format my code when saving, but it's not working.
devcontainer.json
Can anyone help me ensure my code stays clean and organized?
this is repository of deno with devcontainer.
https://github.com/katayama8000/deno-devcontainer
GitHub
GitHub - katayama8000/deno-devcontainer
Contribute to katayama8000/deno-devcontainer development by creating an account on GitHub.
4 Replies
To ensure that your code is automatically formatted on save within a devcontainer using the Deno extension for Visual Studio Code, you've already taken the right steps by setting the appropriate options in your
devcontainer.json
. According to the documentation, the Deno CLI comes with a built-in formatter which can be accessed using deno fmt
and can be configured to be used by Visual Studio Code. The editor.formatOnSave
setting should trigger the formatter on each save, and the editor.defaultFormatter
set to "denoland.vscode-deno"
specifies that the Deno formatter should be used.
Your devcontainer.json
looks correctly configured for this purpose. However, if it's not working as expected, here are a few troubleshooting steps you can take:
1. Ensure the Deno extension is active: When you open the project in the devcontainer, make sure that the Deno extension is active and not showing any errors.
2. Check the Deno version: Make sure that the version of Deno installed in the devcontainer is compatible with the Deno extension in VSCode.
3. Check for conflicting settings: Sometimes, other settings or extensions can interfere with the formatter. Try disabling other extensions temporarily to see if there's a conflict.
4. Check the output of the Deno language server: Use the Deno: Language Server Status
command from the command palette to check the current active configuration and ensure that the language server is recognizing your settings correctly.
5. Reload the window: Sometimes, changes in settings might require you to reload the VSCode window. You can do this by opening the command palette and typing Developer: Reload Window
.
6. Rebuild the devcontainer: If you've made changes to the devcontainer.json
after the containerwas built, you might need to rebuild the container for the changes to take effect.
7. Check the Deno extension documentation: The documentation might have additional information or steps for troubleshooting issues with formatting on save.
If you've gone through these steps and the issue persists, you might want to check the repository's issues or discussions to see if others have encountered similar problems or if there's an ongoing issue with the extension itself. 🦕
Check the documentation here: https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno#formatting
In particular, note that their example puts the default formatter under the
"[typescript]"
keyDeno - Visual Studio Marketplace
Extension for Visual Studio Code - A language server client for Deno.
thank you for the explain 🙂
finally format works!!