chase / vim-ansible-yaml

Add additional support for Ansible in VIM
449 stars 77 forks source link

Issue #16: Strings get wrong colors #25

Closed benjifisher closed 9 years ago

benjifisher commented 9 years ago

This quick fix improves the highlighting for the example in #16.

I do not think that with_items has anything to do with the problem here. The reason the strings are not highlighted is that the yamlScalar syntax group does not allow yamlString inside it; this patch changes that.

A more complete solution to the problem would be to recognize { name: 'Jinja2', version: '2.7.1' } as a flow hash (two keys, each with a value). I do not think this can be done with a quick fix.

benjifisher commented 9 years ago

Maybe what I refer to as a "flow hash" is what #8 calls a "scalar block". If so, then we already have an open issue for a "more complete solution".

chase commented 9 years ago

Scalar blocks, or block scalars, are not what you are referring to, see the YAML spec: http://www.yaml.org/spec/1.2/spec.html#id2793652.

Flow hashes, or flow mappings, are covered in: http://www.yaml.org/spec/1.2/spec.html#id2790832.

The issue indeed has nothing to do with Ansible loops, but entirely has to do with flow mappings not being implemented. For what it is worth, flow sequences are not implemented either.

chase commented 9 years ago

This patch doesn't seem to change the highlighting for the example given in #16 except for allowing the highlight of the } at the end. Comments are still broken. The , delimiter and version mapping are both still highlighted as strings.

testing yml -tmp-roles - vim_001 testing yml -tmp-roles - vim_002

benjifisher commented 9 years ago

Terminology: I was almost right, referring to { name: 'Jinja2', version: '2.7.1' } as a flow hash. The correct term is flow mapping. Thanks for the reminder.

A complete solution to the current problem would require recognizing flow mappings. Do we have an open issue for that?

I see the problem. When I was working on this, I used :hi link yamlString WarningMsg in order to make the difference more visible. Without that, both yamlString and yamlScalar are linked to String, so there is no visible difference. Which of them do you want to change, and to what?

chase commented 9 years ago

16 is requesting support for flow mappings. We could change the title to reflect that.