Menu

#353 Beauty: clang-format plugin for C++

None
closed
None
5
2019-07-19
2015-10-13
Alan Ezust
No

clang-format is a command-line formatting program for C++ that works much better than any other formatting tools.

Discussion

  • Alan Ezust

    Alan Ezust - 2015-10-13

    Ticket moved from /p/jedit/feature-requests/502/

     
  • Dale Anson

    Dale Anson - 2015-10-14

    I did a little googling since I'm in the middle of some Beauty plugin updates anyway, so I thought I might take this on. It looks like clang-format is written in python, which I don't know, and formats C++, which I haven't used in about 15 years, so someone else should make a separate plugin for this. It should be straightforward for someone with python, C++, and java experience to package up a plugin to work with the Beauty plugin. Here are the details from the Beauty plugin docs:

    Adding a new beautifier/formatter is quite simple:

    Write a formatter that implements beauty.beautifiers.Beautifier. You'll need to implement only the String beautify(String text) method. Your formatter will be passed the complete contents of a buffer in the text parameter, and should return formatted text. The buffer contents will be replaced with this returned text. Create a simple plugin that contains this formatter.

    Add a services.xml file to your plugin like this:

    <services>
    <service class="" name="lispy">
    new lisp.lispy.Beautify();
    </service>
    </services>

    For NAME , either use the name of the editing mode that the beautifier supports, or a unique name for your plugin. The beanshell code must return an object that can be cast to beauty.beautifiers.Beautifier .

    For each editing mode that your beautifier supports, add a line to your plugin properties file like this:

    mode.MODENAME.beauty.beautifier=NAME

    where MODENAME is the name of an editing mode that your beautifier supports, and NAME is the same name used in the services.xml file. So continuing the example, you might have:

    mode.lisp.beauty.beautifier=lispy
    

    for your beautifier that supports the Lisp language.

    Release your plugin.

     
  • Eric Le Lay

    Eric Le Lay - 2015-10-15

    A generic "external formatter" would be useful, piping buffer content to an external program and returning the external program's output. It could be developped as part of the clang-format plugin and not worry with the configuration ui at first.

     
  • Dale Anson

    Dale Anson - 2015-12-11

    Alan, I added CLangBeauty in jEdit SVN. It's based on Eric's OuterBeauty and seems to work well. Would you give it a try and if it seems okay, let me know and I'll put in a release request.

     
  • Dale Anson

    Dale Anson - 2015-12-11
    • assigned_to: Dale Anson
    • Group: none -->
     
  • Alan Ezust

    Alan Ezust - 2015-12-11

    I tried it out and it puts all #include statements on the same line. I am pretty sure that is a setting we can configure so it won't do that. Let me investigate before you release it.

     
    • Dale Anson

      Dale Anson - 2015-12-11

      There are a lot of other settings that could be made, I only implemented
      the "style" setting. See this page:
      http://clang.llvm.org/docs/ClangFormatStyleOptions.html

      It would be straightforward to add these to the plugin options.

      On Fri, Dec 11, 2015 at 3:43 PM, Alan Ezust ezust@users.sf.net wrote:

      I tried it out and it puts all #include statements on the same line. I am
      pretty sure that is a setting we can configure so it won't do that. Let me
      investigate before you release it.


      • [plugin-feature-requests:#353] Beauty: clang-format plugin for C++ *

      Status: open
      Group:
      Created: Tue Oct 13, 2015 11:58 PM UTC by Alan Ezust
      Last Updated: Fri Dec 11, 2015 08:53 PM UTC
      Owner: Dale Anson

      clang-format is a command-line formatting program for C++ that works much
      better than any other formatting tools.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/jedit/plugin-feature-requests/353/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Dale Anson

    Dale Anson - 2019-07-19
    • status: open --> closed
     
  • Dale Anson

    Dale Anson - 2019-07-19

    CLangBeauty was released in November of 2016.

     

Log in to post a comment.