Skip to content

Add .clang-format configuration#143

Open
killerdevildog wants to merge 2 commits intoxissburg:masterfrom
killerdevildog:feature/add-clang-format
Open

Add .clang-format configuration#143
killerdevildog wants to merge 2 commits intoxissburg:masterfrom
killerdevildog:feature/add-clang-format

Conversation

@killerdevildog
Copy link

  • Addresses issue Add .clang-format #56 by adding clang-format configuration
  • Based on LLVM style with customizations to preserve project aesthetics
  • Enables AlignConsecutiveAssignments to maintain alignment preferences
  • Sets PointerAlignment to Right for consistency with existing code
  • Preserves include order and maintains 4-space indentation
  • Disables column limit to avoid breaking long expressions
  • Configuration tested to minimize changes to existing codebase

- Addresses issue xissburg#56 by adding clang-format configuration
- Based on LLVM style with customizations to preserve project aesthetics
- Enables AlignConsecutiveAssignments to maintain alignment preferences
- Sets PointerAlignment to Right for consistency with existing code
- Preserves include order and maintains 4-space indentation
- Disables column limit to avoid breaking long expressions
- Configuration tested to minimize changes to existing codebase
@xissburg
Copy link
Owner

xissburg commented Aug 2, 2025

Thanks for the attempt at making this work. This still breaks the code structure in many locations. Perhaps it's not feasible to reproduce the code style in clang-format. It would have to be adapted into a new style.

@killerdevildog
Copy link
Author

Thank you for reviewing this PR, @xissburg.

I appreciate the feedback—it's helpful to know that the current config still introduces some unwanted changes to the code structure. My goal was to get as close as possible to the existing style while leveraging clang-format for consistency moving forward, but I understand if it's not quite there yet.

To make this more actionable, could you point me to a few specific files or locations where the formatting breaks in undesirable ways? That would allow me to tweak the config further (e.g., adjusting rules around alignment, breaks, or other LLVM overrides) and test iterations without overhauling the entire codebase blindly.

Alternatively, if adapting to a slightly new style via clang-format makes sense (perhaps starting from this base and refining it collaboratively), I'm open to that too—it could simplify maintenance long-term while preserving the project's core aesthetics.

What are your thoughts? I'm happy to update the PR accordingly.

@xissburg
Copy link
Owner

xissburg commented Aug 3, 2025

I have pushed a few changes that comes closer to the original style. Though there are still issues I cant quite figure out.
In shared_comp.hpp there is too much indentation.
In raycast.hpp the multiline variant declaration doesn't have a break before the template closing bracket. I found this setting BreakBeforeTemplateCloser which might work but it's only supported on latest clang-format versions. This creates the issue of getting different results on other contributor's machines.
I wish nested namespaces could be indented (edyn::internal, edyn::detail).
simulation_worker.cpp:59 becomes a very long line.
solver.cpp:183-189 gets a little messy.

A couple of issues but it's getting close :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants