rainbow icon indicating copy to clipboard operation
rainbow copied to clipboard

Square bracket in yaml files

Open nameer opened this issue 5 years ago • 2 comments

Describe the bug

Not coloring closing square bracket in YAML files. The bracket is recognized if there is a space between the word and bracket.

To Reproduce

Scenerio 1

repos:
    - repo: local
      hooks:
          - id: myid
            types: [python]
    - repo: local
      hooks:
          - id: secondid
            types: [file, python]

See the color of [ and ] around texts python and file.

Scenerio 2 Opposed to the above, if there is a space as in here:

repos:
    - repo: local
      hooks:
          - id: myid
            types: [python ]
    - repo: local
      hooks:
          - id: secondid
            types: [file, python ]

it works as expected.

Expected behavior

Same color for both opening and closing square brackets, in both scenarios.

Screenshots

Scenario 1 Screenshot from 2020-05-05 11-15-35

Scenario 2 Screenshot from 2020-05-05 11-15-56

nameer avatar May 05 '20 05:05 nameer

Yes, I can reproduce this issue.

I find that it is because this syntax rule of yaml:

execute 'syn match yamlPlainScalar /'.s:ns_plain_out.'/'
execute 'syn match yamlPlainScalar contained /'.s:ns_plain_in.'/'

And find it in :syntax:

yamlPlainScalar xxx match /\%([^\-?:,[\]{}#&*!|>'"%@`\n\r\uFEFF \t]\|[?:\-]\%([^\n\r\uFEFF \t]\)\@=\)\%([
^\n\r\uFEFF \t]#\|:[^\n\r\uFEFF \t]\|[^\n\r\uFEFF \t:#]\)*/
                   match /\%([^\-?:,[\]{}#&*!|>'"%@`\n\r\uFEFF \t]\|[?:\-]\%([^,[\]{}\n\r\uFEFF \t]\)\@=\
)\%([^\n\r\uFEFF \t]#\|:[^,[\]{}\n\r\uFEFF \t]\|[^,[\]{}\n\r\uFEFF \t:#]\)*/  contained

So, the possible solution might be: option1: add syn clear yamlPlainScalar in the "after" configuration field. option2: disable rainbow for yaml seperately.

luochen1990 avatar May 12 '20 06:05 luochen1990

Do I understand correctly that the issue is yamlPlainScalar includes the closing square bracket as part of the scalar? Removing yamlPlainScalar isn't great as it loses the highlighting for the scalar itself...

durka avatar Mar 03 '23 19:03 durka