-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat(query): Add OpenSCAD formatter #845
Conversation
* prevent invalid formatting of `field_definition` that followed an `identifier` * `predicates` parameters are now separated by a `spaced_softline` allowing long predicates to be broken up
Co-authored-by: Christopher Harrison <[email protected]>
7bb4147
to
1c88871
Compare
The code looks fine at first glance, but it seems your Rust tool chain has bumped the Cargo Lock version from 3 to 4, which our CI does not support. Have you built your branch with the dev environment provided by Nix? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great 🙏
I've left one minor comment and, as per @nbacquey's suggestion, we need the Cargo.lock
fixed so we can run our CI.
I have not, should Line 144 in 9e4270c
Would be nice to add step in the flake that does a CI compliant @nbacquey running |
As an aside, it seems like the CI hasn't been getting cache hits in cachix OR GHA cache, is this a known issue? EDIT: I don't know what's failing in CI currently because the log is massive, opening the raw log causes the given firefox tab to crash :(
|
…_item` bodies that are not `union_block`s * Added support for `tree-sitter-openscad` flake
If I run I'm able to prevent the diff --git a/flake.lock b/flake.lock
index 0e645f9..118bdf2 100644
--- a/flake.lock
+++ b/flake.lock
@@ -92,7 +92,8 @@
"crane": "crane",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
- "tree-sitter-nickel": "tree-sitter-nickel"
+ "tree-sitter-nickel": "tree-sitter-nickel",
+ "tree-sitter-openscad": "tree-sitter-openscad"
}
},
"rust-overlay": {
@@ -148,6 +149,26 @@
"repo": "tree-sitter-nickel",
"type": "github"
}
+ },
+ "tree-sitter-openscad": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1737584789,
+ "narHash": "sha256-j/DordcjrrVZ9ZI2p46z4TULyf2A+4mNjcM9btowyQU=",
+ "owner": "mkatychev",
+ "repo": "tree-sitter-openscad",
+ "rev": "270e5ff749edfacc84a6e4a434abd4e8b0f70bbe",
+ "type": "github"
+ },
+ "original": {
+ "owner": "mkatychev",
+ "repo": "tree-sitter-openscad",
+ "type": "github"
+ }
}
},
"root": "root", I'm no Nix expert by any stretch of the imagination, but hopefully that fixes the problem in your branch 🤞 |
In the GitHub Actions view, there's a button on the top-right of the pane that allows you to download the log, rather than viewing it in your browser. Does that work for you? |
#849 bumps the toolchain, so once that's merged, I think that will resolve the Cargo lockfile/CI issue at the source. You may want to rebase once that's merged. |
@mkatychev #849 has now been merged |
89aeb9a
to
b18328d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's all ready, now! Thank you, @mkatychev 🙏
I did notice a double-indent in your expected output. I don't know OpenSCAD, so maybe this is genuinely expected, but I thought I'd flag it before merging...
feat(query): Add OpenSCAD formatter
Description
My work on supporting alternate formatters for
openscad-lsp
exposed a lack of idiomatic formatting for the OpenSCAD DSL with clang falling somewhat short of expectations.The intent of this PR is to build a formatter that is as close as possible to idioms found in popular OpenSCAD libraries such as BOSL2 and standard library.
Cheatsheet for ref of grammar types.
This PR uses a fork of
tree-sitter-openscad
since the main repo has beeninactive for some time: bollian/tree-sitter-openscad#18
topiary/topiary-config/languages.ncl
Lines 78 to 81 in 8809a24
The changes done to
tree-sitter-openscad
have been quite large so there hasbeen at ton of grammar changes behind the scenes to allow these formatting queries to behave idiomatically:
https://github.com/mkatychev/tree-sitter-openscad/blob/master/CHANGELOG.md#version-060
I've done my best to document most of the queries and test in this PR but I'm sure there are things I've missed.
Checklist
Checklist before merging: