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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Ticket moved from /p/jedit/feature-requests/502/
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:
for your beautifier that supports the Lisp language.
Release your plugin.
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.
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.
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.
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:
CLangBeauty was released in November of 2016.