pearofducks / ansible-vim

A vim plugin for syntax highlighting Ansible's common filetypes
MIT License
800 stars 98 forks source link

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

Closed gotmax23 closed 3 years ago

gotmax23 commented 3 years ago

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!

pearofducks commented 3 years ago

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

gotmax23 commented 3 years ago

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

pearofducks commented 3 years ago

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

gotmax23 commented 3 years ago

Got it. Thanks.