How to fold based on indent level in Vim?

1k views Asked by At

I'm writing a syntax file for a new language, ChoiceScript, and it uses indent level to determine scope (i.e. what is in a block) instead of, say, curly braces like in C. Here is some sample code:

    *label start
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. 

    Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. 
    *choice
        #Option A
            *goto next
        *disable_reuse #Option B
            Text about option B here.
            *choice
                #Option B-1
                    Some text about option B-1 here.
                    *goto start
                #Option B-2
                    Some text about option B-2 here.
                    *goto start

    *label next
    Text continues on...

I'd like to write a syntax file that enables folding on the following:

  1. Blocks of text. For example: the two paragraphs under *label start.

  2. A whole *choice block, including all the option blocks.

  3. Option blocks.

0

There are 0 answers