Loading ...
Sorry, an error occurred while loading the content.

Implementing nested braces for syntax folding

Expand Messages
  • Rob Hoelz
    Hi all, I m working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I ve encountered an interesting bug and seek the
    Message 1 of 4 , May 23 12:08 PM
    • 0 Attachment
      Hi all,

      I'm working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I've encountered an interesting bug and seek the community's help. Attached is an example Perl file. When using the HEAD of vim-perl (https://github.com/vim-perl/vim-perl), the three subroutines fold properly with the default settings. However, with perl_fold_anonymous_subs set to 1, the folding for the third subroutine (which has attributes, which seems to trigger this odd behavior), the fold is not properly ended and continues until the end of the file. The opening brace of the subroutine seems to be counted as an inner brace (see the perlBraces rule), even though it's present in the perlSubFold rule (according to synstack), and that's messing up the folding. I understand not everyone has time to look through a complicated several hundred line syntax file, so I've included a minimal syntax file that demonstrates this behavior as well (although min.vim messes up *all* the folds; the problem is the same, though). Could any syntax gurus or Vim developers help me figure out what I'm doing wrong?

      By the way, I'm using Vim 7.3, patch level 1004. If you're testing with a Vim where the patch level is < 970, you'll need to comment out the line setting the regexpengine.

      Thanks,
      Rob

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ben Fritz
      ... I ve wanted for a while to get Perl folding to work based on open-close brace only, instead of relying on indent. Since you are already messing with the
      Message 2 of 4 , May 23 6:29 PM
      • 0 Attachment
        On Thursday, May 23, 2013 2:08:16 PM UTC-5, Rob Hoelz wrote:
        > Hi all,
        >
        >
        >
        > I'm working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I've encountered an interesting bug and seek the community's help. Attached is an example Perl file. When using the HEAD of vim-perl (https://github.com/vim-perl/vim-perl), the three subroutines fold properly with the default settings. However, with perl_fold_anonymous_subs set to 1, the folding for the third subroutine (which has attributes, which seems to trigger this odd behavior), the fold is not properly ended

        I've wanted for a while to get Perl folding to work based on open-close brace only, instead of relying on indent.

        Since you are already messing with the syntax folding, what are the chances of getting that working as part of your updates? I got it working once before it went to github, but I wasn't able to get it working again the last time I tried.

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Rob Hoelz
        ... It s working for the most part; the only problem as of now is that attributes mess things up (as seen in my example). Also, the current rules expect the
        Message 3 of 4 , May 24 12:04 AM
        • 0 Attachment
          On 5/24/13 3:29 AM, Ben Fritz wrote:
          > On Thursday, May 23, 2013 2:08:16 PM UTC-5, Rob Hoelz wrote:
          >> Hi all,
          >>
          >>
          >>
          >> I'm working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I've encountered an interesting bug and seek the community's help. Attached is an example Perl file. When using the HEAD of vim-perl (https://github.com/vim-perl/vim-perl), the three subroutines fold properly with the default settings. However, with perl_fold_anonymous_subs set to 1, the folding for the third subroutine (which has attributes, which seems to trigger this odd behavior), the fold is not properly ended
          > I've wanted for a while to get Perl folding to work based on open-close brace only, instead of relying on indent.
          >
          > Since you are already messing with the syntax folding, what are the chances of getting that working as part of your updates? I got it working once before it went to github, but I wasn't able to get it working again the last time I tried.
          >
          It's working for the most part; the only problem as of now is that
          attributes mess things up (as seen in my example). Also, the current
          rules expect the opening brace to be on the same line, but I don't think
          that would be *too* hard to fix. (famous last words, right?)

          -Rob

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Rob Hoelz
          ... I ve fixed this; after diving into syntax.c for a little bit, I discovered that an empty match group following attributes would fix it. I would like to
          Message 4 of 4 , May 24 3:50 PM
          • 0 Attachment
            On Thursday, May 23, 2013 9:08:16 PM UTC+2, Rob Hoelz wrote:
            > Hi all,
            >
            >
            >
            > I'm working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I've encountered an interesting bug and seek the community's help. Attached is an example Perl file. When using the HEAD of vim-perl (https://github.com/vim-perl/vim-perl), the three subroutines fold properly with the default settings. However, with perl_fold_anonymous_subs set to 1, the folding for the third subroutine (which has attributes, which seems to trigger this odd behavior), the fold is not properly ended and continues until the end of the file. The opening brace of the subroutine seems to be counted as an inner brace (see the perlBraces rule), even though it's present in the perlSubFold rule (according to synstack), and that's messing up the folding. I understand not everyone has time to look through a complicated several hundred line syntax file, so I've included a minimal syntax file that demonstrates this behavior as well (although min.vim messes up *all* the folds; the problem is the same, though). Could any syntax gurus or Vim developers help me figure out what I'm doing wrong?
            >
            >
            >
            > By the way, I'm using Vim 7.3, patch level 1004. If you're testing with a Vim where the patch level is < 970, you'll need to comment out the line setting the regexpengine.
            >
            >
            >
            > Thanks,
            >
            > Rob

            I've fixed this; after diving into syntax.c for a little bit, I discovered that an empty match group following attributes would fix it. I would like to understand how syntax.c works better, though...

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.