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

110613Re: very simple braces based folding

Expand Messages
  • Daniel Fetchinson
    Jan 1, 2010
    • 0 Attachment
      > I'm somewhat confused, as folding works perfectly fine for me
      > even without the patch. Can you please check if your javascript.vim
      > is exactly the same as mine? (see attached).

      Yes, I have the same file, it's the one that ships with vim 7.2

      What I did was copying your javascript.vim to my
      ~/.vim/syntax/javascript.vim and tweaked it there. Now I have what I
      initially wanted, because I changed the folding region to be bounded
      by ^{$ and ^}$ because I always put the opening and closing braces of
      functions in their own lines. Also, I changed the fold text to tell me
      the number of lines and also applied the patch that was sent by
      Christian. And now everything is good!

      Cheers,
      Daniel


      >>> Hi Daniel!
      >>>
      >>> On So, 27 Dez 2009, Daniel Fetchinson wrote:
      >>>
      >>>
      >>>> void x( )
      >>>> -----------------folded--------------
      >>>> void y( )
      >>>> -----------------folded--------------
      >>>>
      >>>> And if the folded regions are unfolded, there are no enclosed folds
      >>>> either (only top level braces are folded).
      >>>>
      >>>> This is all good.
      >>>>
      >>>> Now I have a hard time reproducing all of this with javascript files :(
      >>>>
      >>> If I read syntax/javascript.vim correctly you need to enable syntax
      >>> based folding by setting :let javaScript_fold=1 in e.g. your .vimrc.
      >>>
      >>> However there seems to be a bug with syntax based folding, which
      >>> prevents folding. The following patch works for me (I understand syntax
      >>> rules only very basically), therefore cc'ing the maintainer Claudio
      >>> Fleiner.
      >>>
      >>> chrisbra@256bit:~/local/share/vim/vim72/syntax$ diff -Nu
      >>> javascript.vim{.orig,}
      >>> --- javascript.vim.orig 2009-12-29 14:12:39.000000000 +0100
      >>> +++ javascript.vim 2009-12-29 14:12:42.000000000 +0100
      >>> @@ -47,7 +47,7 @@
      >>> syn keyword javaScriptRepeat while for do in
      >>> syn keyword javaScriptBranch break continue
      >>> syn keyword javaScriptOperator new delete instanceof typeof
      >>> -syn keyword javaScriptType Array Boolean Date Function
      >>> Number
      >>> Object String RegExp
      >>> +syn keyword javaScriptType Array Boolean Date Number Object
      >>> String RegExp
      >>> syn keyword javaScriptStatement return with
      >>> syn keyword javaScriptBoolean true false
      >>> syn keyword javaScriptNull null undefined
      >>>
      >>> The problem seems to be that the syntax keywod javaScriptType
      >>> takes precedence over the defined region javaScriptFunction and
      >>> therefore prevents that the syntax folding applies. Claudio probably
      >>> knows better if this is true and how to fix the problem.
      >>>
      >>> regards,
      >>> Christian
      >>>
      >>
      >> Thanks Christian!
      >>
      >> Your patch does indeed fix the problem!
      >>
      >> Cheers,
      >> Daniel
      >>
      >>
      >>
      >


      --
      Psss, psss, put it down! - http://www.cafepress.com/putitdown

      --
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 7 messages in this topic