Syntax highlighting broken (because incorrect 'file type' in editor)
See original GitHub issueSanity check
- I certify that the
redhat.ansible
extension is in use and the language of the document in this bug report shows up asAnsible
Summary
Unfortunately, https://github.com/ansible/vscode-ansible/issues/293 was closed prematurely, because while the original reporter was helped to manually fix his problem, the problem still persists for new users with no indication other than a closed issue on the source repo as how to fix it.
To be clear: I understand how I can fix the issue for myself, but that still leaves the open issue that syntax highlighting does not work for people that I think should be addressed.
I believe the root cause is the order in which this extension and the YAML extension (also from Red Hat, which was automatically installed along with this extension for me in a fresh VSCode install) are installed. Without further testing (which I can carry out if needed) I would guess that if the user already has the YAML extension installed when installing the Ansible extension, then the Ansible extension takes ‘ownership’ of the .yml
association, but that if neither extension is installed, after installing the Ansible extension, the YAML extension is installed as a dependency and then takes over the association.
Extension version
v0.7.1
VS Code version
1.63.2
Ansible Version
Version: 1.63.2
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:40:02.816Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19044
OS / Environment
Windows 10, WSL, Fedora 31, ansible-lint 5.1.3 using ansible 2.11.4
Relevant log output
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
@Gaibhne
I can’t confirm this, I installed first the YAML extension and then the Ansible extension and all Ansible files are still use YAML language.
@ganeshrn It doesn’t help the user if he must enable the Ansible language for every file. Imagine a folder with 100 Ansible files 😱 So best would be if auto-detection would work out of the box. At least you should provide an example
files.associations
block in the README.I use this one:
This one is mainly inspired from ansible-lint’s detection rules: https://github.com/ansible-community/ansible-lint/blob/03fe3936d8015190744d3756a0a3361380a05adb/src/ansiblelint/config.py#L14-L40
Not a bug.