benoitsan / BBUncrustifyPlugin-Xcode

Xcode plugin to format source code using ClangFormat or Uncrustify
MIT License
1.19k stars 150 forks source link

xcode not formatting code #57

Closed oliver-dungey closed 9 years ago

oliver-dungey commented 10 years ago

I know this one has been raised before but I think there still might be an issue here. I'm using xcode 5.1 with BBUncrustifyPlugin-Xcode 2.0.3 and I have found that UncrustifyX will happily find my configuration file in the root of the project directory (or the various home directory options) if it's named .uncrustifyconfig or uncrustify.cfg but my source files are in a sub directory and never get formatted unless I put a configuration file in every directory. This seems to contradict the instructions.

Seems to me that the logic in UncrustifyX for finding config files might be different from the plugin, dunno.

It would be very handy if the preferences page stated which configuration files it had found and which it was going to use on a given project.

FYI If I use Clang instead of uncrustify it all works nicely.

benoitsan commented 10 years ago

It should work. The uncrustify configuration can be in any parent directory. Here is a working example (http://cl.ly/VhWH), I made a test with the V2.0.3 and there is no issue.

Because there can be multiple configurations for a same project, the configuration file path is not displayed in the preferences. To check wich configuration is used for a given source code file, select the source file in the navigator of Xcode and then use the menu item "Edit Uncrustify Configuration" (in the preferences, set your preferred text editor app to edit the configuration file), it will open the configuration file used for this file.

oliver-dungey commented 10 years ago

Thanks for the swift reply - I can edit the configuration ok but whatever I do I can't seem to get it to format using the configuration I've just edited. The editor does seem to be doing a code format on save but it's just not the format I have specified/edited.

jsievenpiper commented 10 years ago

I'm also experiencing this issue on a new development machine: OS X 10.9.4 & Xcode 5.1.1. The plugin finds the correct uncrustify.cfg file when editing the configuration, but no formatting is done through any of the Format Selection, Format File, etc commands.

When switching to clang-format with the plugin, formatting works as expected. I'm using clang-format for now, but it's not nearly as powerful :(

ghost commented 10 years ago

I had this same issue. If I ran uncrustify from command line it would format the code but, I had a few errors for Unknown symbol. My .cfg was started from a sample .cfg in the Uncrustify source on GitHub an it seems the sample contained either a few new settings or some deprecated settings. Once I commented out the offending lines in my .cfg, BBUncrustifyPlugin started working just fine.

niebloomj commented 9 years ago

how were you able to find out what the offending lines were?

srosmd commented 9 years ago

I'm having this issue as well. Xcode 6.3, Mac OS X 10.10. I can format the files using my .cfg file in uncrustify, but it doesn't execute the formatting in Xcode. It was working great a few days ago. Maybe the new command line tools from Apple broke this somehow?

benoitsan commented 9 years ago

I have added a log viewer. At this time, the log is pretty limited but you will perhaps find an issue in it.

  1. Build the plugin from sources.
  2. Reproduce the issue.
  3. Go to Edit > Format Code > View Log

screen shot 2015-04-15 at 23 38 55