vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Cannot set up redhat.vscode-yaml as formatter for ansible.

Open DeadNews opened this issue 2 years ago • 5 comments

Ref: https://github.com/ansible/vscode-ansible/issues/597

.vscode/extensions.json:

{
    // List of extensions which should be recommended for users of this workspace.
    "recommendations": [
        "redhat.ansible",
        "redhat.vscode-yaml",
    ]
}

.vscode/settings.json:

// Workspace settings override user settings.
{
    "files.associations": {
        "*.j2": "ansible-jinja",
        "**/defaults/**/*.yml": "ansible-jinja",
        "**/group_vars/**/*": "ansible-jinja",
        "**/host_vars/**/*": "ansible-jinja",
        "**/vars/**/*.yml": "ansible-jinja",
        "**/tasks/**/*.yml": "ansible",
        "**/handlers/*.yml": "ansible",
        "**/meta/*.yml": "ansible",
        "**/roles/**/*.yml": "ansible",
        "**/playbooks/**/*.yml": "ansible",
        "**/ansible/**/hosts": "properties",
        "**/ansible/**/inventory": "properties",
        "ansible.cfg": "properties",
    },
    "[ansible]": {
        "editor.defaultFormatter": "redhat.vscode-yaml",
        "editor.formatOnSave": true,
    },
    // redhat.ansible
    "ansible.ansibleLint.enabled": true,
    "ansible.ansibleLint.arguments": "",
}

When I press Format document, vscode complains that There is no formatter for 'ansible' files installed.

Everything works, if replace "editor.defaultFormatter": "redhat.vscode-yaml", with "editor.defaultFormatter": "esbenp.prettier-vscode",.

So it's looks like redhat.vscode-yaml issue.

DeadNews avatar Aug 26 '22 13:08 DeadNews

Ref: https://github.com/prettier/prettier-vscode/issues/1259

DeadNews avatar Sep 05 '22 08:09 DeadNews

Surprised to find out that redhat.vscode-yaml didn't work with ansible. Look forward to this feature being added.

yanghua-ola avatar Nov 08 '22 03:11 yanghua-ola

I'm the same here, but it works if I switch the file type to yaml, format, and then back to ansible.

Looks like some erroneous checks for currently selected file type in redhat.vscode-yaml.

Any news on this? Neither redhat.ansible nor redhat.vscode-yaml extension seem to be able to handle Ansible files...

sinux-l5d avatar Feb 06 '24 15:02 sinux-l5d

Any news on this? Neither redhat.ansible nor redhat.vscode-yaml extension seem to be able to handle Ansible files...

I am also waiting for, no luck yet!

tabish-javed avatar Jun 25 '24 16:06 tabish-javed