Skip to content
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 document formatting feature OR set YAML extension's formatter on ansible playbooks. #1114

Open
tabish-javed opened this issue Mar 4, 2024 · 2 comments
Labels
feature New feature or request

Comments

@tabish-javed
Copy link

tabish-javed commented Mar 4, 2024

Problem

No formatter support on ansible playbooks in VS-Code.

Solution

Add formatter support to ansible's extension.

Alternatives

Tweak ansible extension to use YAML extension as default formatter.

Additional context

No response

@tabish-javed tabish-javed added feature New feature or request new labels Mar 4, 2024
@Qalthos Qalthos removed the new label Mar 6, 2024
@priyamsahoo
Copy link
Contributor

This is a compatible issue with the YAML extension. We have default formatting set up in our extension, and we do not want to rely on the YAML extension to do it.

Having said that, you can always set up a default extension for ansible language and point it to the YAML extension or prettier. prettier seems to work well with the ansible language. If the YAML extension is not formatting it, you might have to raise an issue with their extension to support formatting for ansible language.

Here's how you can set up the formator. Add these to your settings configuration:

"[ansible]": {
    "editor.autoIndent": "advanced",
    "editor.defaultFormatter": "redhat.vscode-yaml",
    "editor.formatOnSave": true
  }

@tabish-javed
Copy link
Author

@priyamsahoo - Thanks for the note!

  • Yes! I am running the same code in my editor settings but doesn't work. VS-Code underlines "editor.defaultFormatter": "redhat.vscode-yaml" in yellow and say, Value is not accepted.
  • Neither the default Ansible Extension seems be supporting document format as it doesn't add formatting command to VS-Code.
  • I will raise a new issue specific to Ansible Extension for sure!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants