pearofducks / ansible-vim

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

Do not highlight "name" that is part of a module #109

Closed savchenko closed 4 years ago

savchenko commented 4 years ago

Consider the following:

- name: Create xfer user
  user:
    name: "{{ agent_name }}"
    shell: /bin/sh
    groups: agents

And here is the highlight: image

I would imagine that second "name" should have the same highlight group as the "shell" and "groups".

pearofducks commented 4 years ago

I'm almost positive this isn't fixable. The YAML syntax simply doesn't convey the structure information necessary to prevent this. The syntax know's it's in a YAML key, but because of how Ansible and YAML work, that name key could be at any level of nesting and we can't reliably pick this up to prevent it.

This is also enough of a corner-case in highlighting I don't think it's worth the excess code trying to work around.

That being said, if someone comes up with a very elegant solution to this, I'm happy to accept a PR.