pearofducks / ansible-vim

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

Plugin doesn't seem to recognize syntax #75

Closed miguellavalle closed 5 years ago

miguellavalle commented 5 years ago

Hi,

This is a continuation to https://github.com/pearofducks/ansible-vim/issues/74. Trying to debug the issue, I added the following to my .vimrc:

map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"

When editing this file https://github.com/miguellavalle/OpenStack-tools/blob/master/ansible/nova-net-migration/prep-compute-nodes-migration.yml, if I place the cursor on top of "name" in line 8, the echo I get is:

hi<> trans<> lo<>

So it's not recognizing the syntax. The only thinks that seem to be recognized are attributes like "path" in line 9 (hi trans lo and jinja variables and delimiters, like in line 13 (hi trans lo and hi trans lo). Would this be attributable toi the plugin?

pearofducks commented 5 years ago

No, this still doesn't sound like a problem with this plugin.

What do you get if you do echo &ft with that file open?

miguellavalle commented 5 years ago

I get: ansible

miguellavalle commented 5 years ago

I cloned this repo: https://github.com/ansible/ansible-examples. With the playbooks in this repo I do get what seems to be proper syntax highlighting. So it is something with my repo. Maybe I am missing files in my repo. What are the assumptions made the plugin in regards to the structure of the entire repo?

miguellavalle commented 5 years ago

Now I know what the problem is: https://github.com/miguellavalle/OpenStack-tools/blob/master/ansible/nova-net-migration/prep-compute-nodes-migration.yml#L1. If your ansible project / repo is not structured with the correct directories to enable automatic file type recognition (as per https://github.com/pearofducks/ansible-vim#introduction), then that line has to be:

vim:ft=yaml.ansible:

miguellavalle commented 5 years ago

Thanks for your help and prompt follow up ;-)

pearofducks commented 5 years ago

Glad you were able to get things resolved!