pearofducks / ansible-vim

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

Vim's YAML syntax - minor bugs #22

Closed pearofducks closed 6 years ago

pearofducks commented 8 years ago

21 and #6 refer to bugs in the underlying YAML syntax highlighting. These can be reproduced in the YAML filetype as well as.

to do: Find an alternative base-syntax to inherit from, or patch over these bugs?

bitozoid commented 6 years ago

How about setting a compound filetype like ansible.yaml?

It would fix https://github.com/w0rp/ale/issues/1024.

pearofducks commented 6 years ago

I'd be willing to accept a PR that uses compound filetypes for ansible successfully and doesn't introduce breaking changes. I tested a few alterations of ftdetect and syntax, and it doesn't appear to be a trivial change — e.g. simply setting the filetype to ansible.yaml does not load the ansible.vim syntax file at all!

bitozoid commented 6 years ago

This seems to work for me. I get ansible.vim syntax indeed.

diff --git a/ftdetect/ansible.vim b/ftdetect/ansible.vim
index 161130a..e8cae8a 100644
--- a/ftdetect/ansible.vim
+++ b/ftdetect/ansible.vim
@@ -12,6 +12,6 @@ function! s:isAnsible()
   return 0
 endfunction

-:au BufNewFile,BufRead * if s:isAnsible() | set ft=ansible | en
+:au BufNewFile,BufRead * if s:isAnsible() | set ft=ansible.yaml | en
 :au BufNewFile,BufRead *.j2 set ft=ansible_template
 :au BufNewFile,BufRead hosts set ft=ansible_hosts
pearofducks commented 6 years ago

Ah, I suspect my plug config was causing the changes to not propagate properly. That does mean this would be a breaking change, so I'd prefer to put it behind a flag — but that shouldn't be a big deal.

Just for reference my config is Plug 'pearofducks/ansible-vim', { 'for': ['ansible','ansible_template','ansible_hosts'] }

I'll look into this more tomorrow.

pearofducks commented 6 years ago

@bitozoid - your changeset does provide ansible.vim syntax, but it's effectively a no-op — compound filetypes are layered in order, so ansible.yaml puts yaml syntax over top of the ansible plugin...and this isn't very interesting for us to do

what is interesting/useful is yaml.ansible as a compound filetype, because then we can ask Vim to source the yaml filetype for us, which cleans up our yaml sourcing a bit IMO.

this change is pushed to the compound-filetype branch here, does it also resolve your bug?

pearofducks commented 6 years ago

Please see the latest version of this plugin, most issues described here are now fixed in some form or another.