pearofducks/ansible-vim

[Bug] Files ending in `.yml.j2` do not have correct syntax highlighting

Closed this issue · 4 comments

The title explains the issue. Files ending in .yml.j2 should have filetype=yaml.jinja2. Both .yml and .yaml endings already work correctly for playbooks; only jinja2 yml templates have this issue. It is possible to fix this issue by adding the following code snippet to the file or replacing .yml.j2 with .yaml.j2, but it is inconvenient.

{#
# vim: set filetype=yaml.jinja2:
#}

Thanks for your help and for the great plugin!

I'm pretty sure this is already covered by the g:ansible_template_syntaxes option?

Hi,

Thank you for pointing me in the right direction! I added the following line to my .vimrc and it fixes the problem.

" Fix syntax highlighting for *.yml.j2 files
let g:ansible_template_syntaxes = { '*.yml.j2': 'yaml' }

Does it make sense to add functionality to the plugin to automatically detect the correct filetype for .yml.j2 files or should I just close this issue?

Thanks,
Maxwell

All *.j2 is supported via that functionality, glad this worked!

Got it. Thanks.