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

Tags/attributes for indentation

Expand Messages
  • David Baelde
    Hi, I m the author of omlet, an indentation mode for Ocaml. I gave up developing and even maintaining it, and I m looking for a good way to restart it from
    Message 1 of 3 , Sep 4, 2008
      Hi,

      I'm the author of omlet, an indentation mode for Ocaml. I gave up
      developing and even maintaining it, and I'm looking for a good way to
      restart it from scratch.

      Currently, the code does some minimal (but not so trivial) parsing of
      the code before the pointer to find out how to indent a line. This was
      developed by hand and incrementally, and quickly became messy. Since
      then I have developed standalone tools that incrementally parse (correct
      regions of) code and indent it based on the yacc grammar and a few
      simple rules. This is much nicer, but seems hard to use from vim. (In
      fact I realized that it is similar to the earlier vim-dev discussion
      about on-the-fly syntax checking with an LALR parser [1]).

      Basically, I would need to attach parsing information to places in the
      buffer. (The info I need requires more complex parsing than what vim
      syntax support can give me.) Is there any builtin device for doing that,
      or do I have to maintain my own structure all the way through edition?
      has anything like that been done already?

      Cheers,

      David

      [1] http://thread.gmane.org/gmane.editors.vim.devel/19346/focus=19381

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... Vim syntax highlighting is pretty powerful (more than I care to delve into throroughly), but if it is still not enough for you, I suppose you could write
      Message 2 of 3 , Sep 5, 2008
        On 04/09/08 17:08, David Baelde wrote:
        > Hi,
        >
        > I'm the author of omlet, an indentation mode for Ocaml. I gave up
        > developing and even maintaining it, and I'm looking for a good way to
        > restart it from scratch.
        >
        > Currently, the code does some minimal (but not so trivial) parsing of
        > the code before the pointer to find out how to indent a line. This was
        > developed by hand and incrementally, and quickly became messy. Since
        > then I have developed standalone tools that incrementally parse (correct
        > regions of) code and indent it based on the yacc grammar and a few
        > simple rules. This is much nicer, but seems hard to use from vim. (In
        > fact I realized that it is similar to the earlier vim-dev discussion
        > about on-the-fly syntax checking with an LALR parser [1]).
        >
        > Basically, I would need to attach parsing information to places in the
        > buffer. (The info I need requires more complex parsing than what vim
        > syntax support can give me.) Is there any builtin device for doing that,
        > or do I have to maintain my own structure all the way through edition?
        > has anything like that been done already?
        >
        > Cheers,
        >
        > David
        >
        > [1] http://thread.gmane.org/gmane.editors.vim.devel/19346/focus=19381

        Vim syntax highlighting is pretty powerful (more than I care to delve
        into throroughly), but if it is still not enough for you, I suppose you
        could write your own function, set it by "setlocal
        indentexpr=OcamlOmlet()" or similar in the appropriate indent/ocaml.vim
        script -- and there you could use as complex processing as you cared to.

        Of course, your script should still indent the code correctly after
        pasting code in the middle, and it ought to be able to compute the
        indent correctly when the user hits <Enter> in Insert mode.

        I notice that there already exists an indent/ocaml.vim in $VIMRUNTIME,
        maintained by Jean-Fran├žois Yuen, Mike Leary and Markus Mottl. You might
        want to look at what that script already does and/or discuss the matter
        with these people (assuming they can still be reached).

        Best regards,
        Tony.
        --
        The first Great Steward, Parrafin the Climber, was employed in King
        Chloroplast's kitchen as second scullery boy when the old King met a
        tragic death. He apparently fell backward by accident on a dozen salad
        forks. Simultaneously the true heir, his son Carotene, mysteriously
        fled the city, complaining of some sort of plot and a lot of
        threatening notes left on his breakfast tray. At the time, this looked
        suspicious what with his father's death, and Carotene was suspected of
        foul play. Then the rest of the King's relatives began to drop dead
        one after the other in an odd fashion. Some were found strangled with
        dishrags and some succumbed to food poisoning. A few were found
        drowned in the soup vats, and one was attacked by assailants unknown
        and beaten to death with a pot roast. At least three appear to have
        thrown themselves backward on salad forks, perhaps in a noble gesture
        of grief over the King's untimely end. Finally there was no one left
        in Minas Troney who was either eligible or willing to wear the accursed
        crown, and the rule of Twodor was up for grabs. The scullery slave
        Parrafin bravely accepted the Stewardship of Twodor until that day when
        a lineal descendant of Carotene's returns to reclaim his rightful
        throne, conquer Twodor's enemies, and revamp the postal system.
        -- Harvard Lampoon, "Bored of the Rings"

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • David Baelde
        Hi, ... Thanks for your reply, but that s already what omlet and the standard ocaml indentation do. In both cases, the function does a bit of parsing, relies a
        Message 3 of 3 , Sep 6, 2008
          Hi,

          Tony Mechelynck wrote:
          > Vim syntax highlighting is pretty powerful (more than I care to delve
          > into throroughly), but if it is still not enough for you, I suppose you
          > could write your own function, set it by "setlocal
          > indentexpr=OcamlOmlet()" or similar in the appropriate indent/ocaml.vim
          > script -- and there you could use as complex processing as you cared to.

          Thanks for your reply, but that's already what omlet and the standard ocaml
          indentation do. In both cases, the function does a bit of parsing, relies a
          bit on the syntax attributes, and indents. But it does not store any parsing
          information in a global variable, so everything is to be done again the next
          time. Basically I'm asking whether there's a simple way to store these parsing
          attributes, without having to maintain them to much as the user edits the
          buffer.

          Regarding the power of vim syntax highlighting, I don't know it in depth
          but I'm quite sure that it doesn't match a proper LALR parser. Now another
          question is whether I really need a full parser to indent ocaml code. I'm not
          sure either, but the part I needed and wrote by hand was insufficient and
          already complex enough for me to want to generate it from the grammar.

          Cheers,

          David

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