Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a formatter #21

Open
matthew-viglione opened this issue May 13, 2021 · 3 comments
Open

Adding a formatter #21

matthew-viglione opened this issue May 13, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@matthew-viglione
Copy link

I recently realized this wonderful extension does not include a formatter. After looking around I found there aren't really any good ones out there and this would great to add. I'll see if I can do it in my spare time, but maybe in the meantime someone else knows of one or a workaround? (Maybe using a formatter for another similar language?)

@Antyos
Copy link
Owner

Antyos commented May 19, 2021

Sorry for the late response!

I am not aware of any OpenSCAD formatters, but I'd love to have one in the extension!

While I am sure there are some formatters that could be used as a starting point, like perhaps one used by a C-like language or maybe even JavaScript, I don't think it could be used in its raw form. OpenSCAD has different syntax for things like the module keyword, as well as several unique language characteristics.

For example, how "should" the following code be formatted?

translate([0, 0, 10]) rotate([90, 0, 0]) translate([10, 0, 0]) cylinder(r=5, d=10);

// Or

translate([0, 0, 10])
  rotate([90, 0, 0])
  translate([10, 0, 0])
  cylinder(r=5, d=10);

// Or

translate([0, 0, 10])
  rotate([90, 0, 0])
    translate([10, 0, 0])
      cylinder(r=5, d=10);

I'm sure there are plenty of other things I'm not thinking of too. That is not to say I am not on board with this idea, I would absolutely love to have a formatted, I just think it's worth talking about the implementation or formatting guidelines to be implemented.

@Antyos Antyos added the enhancement New feature or request label May 19, 2021
@moisout
Copy link

moisout commented Jul 10, 2021

There is https://github.com/Maxattax97/openscad-format, which uses ClangFormat. Or maybe you have already seen that.

@matthew-viglione
Copy link
Author

@mauriceoegerli I haven't seen this before, I'll go give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants