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

Indent fold method for Groovy files

Expand Messages
  • Nathan Neff
    Hello, I would like to create a foldexpr that turns this Groovy closure: def list = { if (!params.max) params.max = 10 [personList: Person.list(params)] } def
    Message 1 of 3 , May 26, 2009
    • 0 Attachment
      Hello,

      I would like to create a foldexpr that turns this Groovy closure:

      def list = {
      if (!params.max) params.max = 10
      [personList: Person.list(params)]
      }

      def show = {
      blah
      blah
      blah
      }


      Into this fold text:

      def list = {
      def show = {

      Currently, I'm using foldmethod=indent, because all the closures start
      on the 5th character.

      I'm messing around with the foldtext setting, but can't get Vim to
      quit displaying a line containing a bunch of dashes and how many
      lines have been folded, which I really don't care about.

      Thanks in advance,

      --Nate

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... I don t know if your Groovy syntax script sets folding, but anyway it ought not to be too hard: try this (untested) If it does, ... If it doesn t, ...
      Message 2 of 3 , Jun 1, 2009
      • 0 Attachment
        On 27/05/09 05:32, Nathan Neff wrote:
        >
        > Hello,
        >
        > I would like to create a foldexpr that turns this Groovy closure:
        >
        > def list = {
        > if (!params.max) params.max = 10
        > [personList: Person.list(params)]
        > }
        >
        > def show = {
        > blah
        > blah
        > blah
        > }
        >
        >
        > Into this fold text:
        >
        > def list = {
        > def show = {
        >
        > Currently, I'm using foldmethod=indent, because all the closures start
        > on the 5th character.
        >
        > I'm messing around with the foldtext setting, but can't get Vim to
        > quit displaying a line containing a bunch of dashes and how many
        > lines have been folded, which I really don't care about.
        >
        > Thanks in advance,
        >
        > --Nate

        I don't know if your Groovy syntax script sets folding, but anyway it
        ought not to be too hard: try this (untested)

        If it does,
        :setlocal foldmethod=syntax

        If it doesn't,
        :setlocal foldmethod=marker foldmarker={,}

        To avoid the bunch of dashes and number of lines folded (also untested):

        :setlocal fillchars=fold:\ foldtext=getline(v:foldstart)
        " with at least two spaces after the backslash


        Best regards,
        Tony.
        --
        Really heard in court in the U.S.A.:
        Q.: Doctor, is it really true that when someone dies while sleeping, he
        or she
        doesn't realize it until the next morning?
        A.: Is it really true that you passed your exams before being admitted
        to the
        Bar?

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Nathan Neff
        ... Thank you very much, Tony. This works great. The groovy syntax script doesn t set folding, so I ... I really appreciate this. --Nate On Mon, Jun 1, 2009
        Message 3 of 3 , Jun 2, 2009
        • 0 Attachment
          > I don't know if your Groovy syntax script sets folding, but anyway it
          > ought not to be too hard: try this (untested)
          >
          > If it does,
          > :setlocal foldmethod=syntax
          >
          > If it doesn't,
          > :setlocal foldmethod=marker foldmarker={,}
          >
          > To avoid the bunch of dashes and number of lines folded (also untested):
          >
          > :setlocal fillchars=fold:\ foldtext=getline(v:foldstart)
          > " with at least two spaces after the backslash

          Thank you very much, Tony.

          This works great. The groovy syntax script doesn't set folding, so I
          had to follow the 2nd and 3rd steps that you outlined above:
          > :setlocal foldmethod=marker foldmarker={,}
          > " Put two spaces after the backslash
          > :setlocal fillchars=fold:\ foldtext=getline(v:foldstart)

          I really appreciate this.

          --Nate

          On Mon, Jun 1, 2009 at 2:03 PM, Tony Mechelynck
          <antoine.mechelynck@...> wrote:
          >
          > On 27/05/09 05:32, Nathan Neff wrote:
          >>
          >> Hello,
          >>
          >> I would like to create a foldexpr that turns this Groovy closure:
          >>
          >>      def list = {
          >>          if (!params.max) params.max = 10
          >>          [personList: Person.list(params)]
          >>      }
          >>
          >>      def show = {
          >>          blah
          >>          blah
          >>          blah
          >>      }
          >>
          >>
          >> Into this fold text:
          >>
          >>      def list = {
          >>      def show = {
          >>
          >> Currently, I'm using foldmethod=indent, because all the closures start
          >> on the 5th character.
          >>
          >> I'm messing around with the foldtext setting, but can't get Vim to
          >> quit displaying a line containing a bunch of dashes and how many
          >> lines have been folded, which I really don't care about.
          >>
          >> Thanks in advance,
          >>
          >> --Nate
          >
          > I don't know if your Groovy syntax script sets folding, but anyway it
          > ought not to be too hard: try this (untested)
          >
          > If it does,
          >        :setlocal foldmethod=syntax
          >
          > If it doesn't,
          >        :setlocal foldmethod=marker foldmarker={,}
          >
          > To avoid the bunch of dashes and number of lines folded (also untested):
          >
          >        :setlocal fillchars=fold:\  foldtext=getline(v:foldstart)
          >        " with at least two spaces after the backslash
          >
          >
          > Best regards,
          > Tony.
          > --
          > Really heard in court in the U.S.A.:
          > Q.: Doctor, is it really true that when someone dies while sleeping, he
          > or she
          >     doesn't realize it until the next morning?
          > A.: Is it really true that you passed your exams before being admitted
          > to the
          >     Bar?
          >
          > >
          >

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.