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

feat(query): Add OpenSCAD formatter #845

Merged
merged 48 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a88f19d
init
mkatychev Aug 29, 2024
81bde88
Merge branch 'main' into feat/openscad
mkatychev Jan 8, 2025
a44493e
initial input test file
mkatychev Jan 8, 2025
961cdf7
handled unnested function formatting
mkatychev Jan 9, 2025
69c8b3f
tree_sitter_query changes:
mkatychev Jan 9, 2025
4fe4b25
added to changelog
mkatychev Jan 9, 2025
ca60f42
added var_declaration to openscad query
mkatychev Jan 10, 2025
79c559b
Update CHANGELOG.md
mkatychev Jan 10, 2025
df5b28d
interim commit
mkatychev Jan 11, 2025
c0e4329
Merge branch 'fix/ts-query-formatting' into feat/openscad
mkatychev Jan 11, 2025
2dea7e7
handle indentation of predicate parameters
mkatychev Jan 11, 2025
2aaaf38
fixup expected header
mkatychev Jan 11, 2025
2add142
handle predicate_type spacing
mkatychev Jan 11, 2025
4619310
Merge branch 'fix/ts-query-formatting' into feat/openscad
mkatychev Jan 12, 2025
a71e62c
formatted if/else block without union
mkatychev Jan 12, 2025
68a7c1c
inital else/if with union block case
mkatychev Jan 12, 2025
7e97d2d
added unionless if else case
mkatychev Jan 12, 2025
d921650
else edge cases
mkatychev Jan 14, 2025
e76c949
added if_block test cases
mkatychev Jan 15, 2025
8c43e14
simplified if_block test case
mkatychev Jan 15, 2025
29c96c5
initial modifier queries
mkatychev Jan 15, 2025
dbffcb4
added initial assertion test case
mkatychev Jan 15, 2025
8bca52d
initial assertions pass
mkatychev Jan 16, 2025
6f9f523
handled
mkatychev Jan 16, 2025
30cb386
Merge branch 'main' into feat/openscad
mkatychev Jan 16, 2025
df70038
partial list handling
mkatychev Jan 20, 2025
d4cb8ab
added ternary test case
mkatychev Jan 21, 2025
97a6ac7
added more ternary cases
mkatychev Jan 21, 2025
4a72741
handled semicolon use statements
mkatychev Jan 21, 2025
fd4beeb
added comprehension cases
mkatychev Jan 21, 2025
669bb4f
added function literal test cases
mkatychev Jan 21, 2025
8809a24
* Added README documentation for OpenSCAD
mkatychev Jan 21, 2025
dabdc42
added wasm update and CHANGELOG
mkatychev Jan 21, 2025
1696713
Merge branch 'main' into feat/openscad
mkatychev Jan 21, 2025
7afe496
Cargo.lock update
mkatychev Jan 21, 2025
1c88871
revert rust changes
mkatychev Jan 22, 2025
0ce5fa0
revision for query lib docstring
mkatychev Jan 22, 2025
93b9107
* Added openscad formatting query for handling indentaiton of `module…
mkatychev Jan 22, 2025
e5324bc
nix flake update
mkatychev Jan 22, 2025
dae66d9
updated expected ternary formatting
mkatychev Jan 22, 2025
cc59db4
revert local dylib for openscad in languages.ncl
mkatychev Jan 22, 2025
22aadf7
Merge branch 'main' into feat/openscad
mkatychev Jan 22, 2025
04cadb1
cargo clippy --fix
mkatychev Jan 22, 2025
efd2f06
updated refs to latest master of tree-sitter-openscad
mkatychev Jan 22, 2025
4badc3e
update formatting
mkatychev Jan 24, 2025
f3aa741
Merge branch 'main' into feat/openscad
mkatychev Jan 24, 2025
b18328d
Merge branch 'main' into feat/openscad
mkatychev Jan 27, 2025
a72b7a4
Merge branch 'main' into feat/openscad
Xophmeister Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ insert_final_newline = true
indent_style = space
indent_size = 4

[*.{json,nix,scm}]
[*.{json,nix,scm,scad}]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This name should be decided amongst the team before the release.
- [#786](https://github.com/tweag/topiary/pull/786) Re-introduce tests to check that all of the language queries are useful.
- [#747](https://github.com/tweag/topiary/pull/747) Added support for specifying paths to prebuilt grammars in Topiary's configuration
- [#832](https://github.com/tweag/topiary/pull/832) Added `typos-cli` to workspace `Cargo.toml` for spellchecking @mkatychev
- [#845](https://github.com/tweag/topiary/pull/747) Added support for OpenSCAD, @mkatychev

### Changed
- [#794](https://github.com/tweag/topiary/pull/794) Bump the `tree-sitter` dependency to 0.24, thanks to @ZedThree
Expand Down
58 changes: 29 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ external contributors. They are built in, by default, so are exposed in
the same way as supported languages.

* [CSS] by @lavigneer
* [OpenSCAD] by @mkatychev

#### Experimental

Expand Down Expand Up @@ -1737,6 +1738,7 @@ of choice open in another.
[ocamlformat]: https://github.com/ocaml-ppx/ocamlformat
[ocamllex]: https://v2.ocaml.org/manual/lexyacc.html
[ocp-indent]: https://www.typerex.org/ocp-indent.html
[openscad]: https://en.wikipedia.org/wiki/OpenSCAD
[ormolu]: https://github.com/tweag/ormolu
[prettier]: https://prettier.io/
[rust]: https://www.rust-lang.org
Expand Down
15 changes: 14 additions & 1 deletion bin/update-wasm-grammars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,20 @@ css() {
echo -e "${GREEN}CSS: Done${NC}"
}

openscad() {
echo -e "${BLUE}OpenSCAD: Fetching${NC}"
REPO=$(repo_for_language "openscad")
git clone "${REPO}" "${WORKDIR}/tree-sitter-openscad" &> /dev/null
REV=$(ref_for_language "opescad")
pushd "${WORKDIR}/tree-sitter-openscad" &> /dev/null
git checkout "$REV" &> /dev/null
popd &> /dev/null
echo -e "${ORANGE}OpenSCAD: Building${NC}"
tree-sitter build --wasm "${WORKDIR}/tree-sitter-openscad"
echo -e "${GREEN}OpenSCAD: Done${NC}"
}


(trap 'kill 0' SIGINT; json & nickel & ocaml & ocamllex & bash & rust & toml & tree-sitter-query & css & wait)
(trap 'kill 0' SIGINT; json & nickel & ocaml & ocamllex & bash & rust & toml & tree-sitter-query & css & openscad & wait)

echo -e "${GREEN}Done! All grammars have been updated${NC}"
6 changes: 4 additions & 2 deletions topiary-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ default = [
"ocaml_interface",
"ocamllex",
"toml",
"tree_sitter_query"
"tree_sitter_query",
]

# Included by default
contributed = [
"css"
"css",
"openscad",
]

# Excluded by default
Expand All @@ -86,6 +87,7 @@ nickel = ["topiary-config/nickel", "topiary-queries/nickel"]
ocaml = ["topiary-config/ocaml", "topiary-queries/ocaml"]
ocaml_interface = ["topiary-config/ocaml_interface", "topiary-queries/ocaml_interface"]
ocamllex = ["topiary-config/ocamllex", "topiary-queries/ocamllex"]
openscad = ["topiary-config/openscad", "topiary-queries/openscad"]
rust = ["topiary-config/rust", "topiary-queries/rust"]
toml = ["topiary-config/toml", "topiary-queries/toml"]
tree_sitter_query = ["topiary-config/tree_sitter_query", "topiary-queries/tree_sitter_query"]
3 changes: 3 additions & 0 deletions topiary-cli/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ where
#[cfg(feature = "ocamllex")]
"ocamllex" => Ok(topiary_queries::ocamllex().into()),

#[cfg(feature = "openscad")]
"openscad" => Ok(topiary_queries::openscad().into()),

#[cfg(feature = "rust")]
"rust" => Ok(topiary_queries::rust().into()),

Expand Down
3 changes: 3 additions & 0 deletions topiary-cli/tests/sample-tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ fn input_output_tester() {
#[cfg(feature = "ocamllex")]
io_test("ocamllex.mll");

#[cfg(feature = "openscad")]
io_test("openscad.scad");

#[cfg(feature = "rust")]
io_test("rust.rs");

Expand Down
Loading
Loading