Sublime Forum

[Resolved] Scope in scope - Own spin syntax

#1

Hello, I want create own syntax for spin text, but i have problem with next level brackets.

Here is example:

{111111 {222222|22222|{3333333|33333}|22222}11111 111111 111111 {22222|22222}11111}|{111111{2222|222}1111}

I need first level of my spin with red color next level blue and next level green.

I know how to create 1 level with:
- match: '{' scope: first push: first first: - meta_scope: first - match: "}" pop: true

Can you help me how to put scope into scope? Sorry for my bad english I hope you understeand. I need bracket “{” in brackets “{ }” with another color and bracket in bracket in bracket with another color too.

0 Likes

#2
- match: \{
  push:
    # "red" scoping here
    - match: \}
      pop: true
    - match: \{
      push:
        # "blue" scoping here
        - match: \}
          pop: true
        - match: \{
          push:
            # "green" scoping here
            - match: \}
              pop: true
2 Likes

#3

Thank you for reply, but I have still same problem. When I copy your code it not works. When I type code with my solution, I have not what i need (https://ctrlv.cz/SuyO)

Here is my code, can u repair it please? I have scopes with name “spin” “spin2” “spin3”.

%YAML 1.2
---
name: Spin
file_extensions:
  - Spin
scope: source.example-c
contexts:
  main:

    - match: '{'
      scope: spin
      push: spin
    - match: "{"
      scope: spin2
      push: spin2

  spin:
    - meta_scope: spin
    - match: "}"
      pop: true
  spin2:
    - meta_scope: spin2
    - match: "}"
      pop: true

Sorry for my bad english. I hope you understeand. Thank you for your time.

0 Likes

#4

I tried everything with your solution, but i take errors. Screenshot: https://ctrlv.cz/F5Ga

I am newbie with YAML and own syntax. Can anyone send me a complete solution? Thanks for help.

0 Likes

#5
- match: \{
  push:
    - meta_scope: spin1 # "red" scoping here
    - match: \}
      pop: true
    - match: \{
      push:
        - meta_scope: spin2 # "blue" scoping here
        - match: \}
          pop: true
        - match: \{
          push:
            - meta_scope: spin3 # "green" scoping here
            - match: \}
              pop: true
2 Likes

#6

Thank you! I did not know before “meta_scope” only “scope”. You are super ! =)

0 Likes