tweag / topiary

https://topiary.tweag.io/
MIT License
579 stars 29 forks source link

WIP nix #771

Open domenkozar opened 1 month ago

domenkozar commented 1 month ago

Couldn't figure out why tree-parser for Nix doesn't work:

echo "1" | ./target/debug/topiary format -l nix
[2024-10-17T16:21:07Z ERROR topiary] Nickel error: ImportError(ParseErrors(ParseErrors { errors: [UnexpectedToken(RawSpan { src_id: FileId(1), start: ByteIndex(506), end: ByteIndex(507) }, ["\"!\"", "\"\\\"\"", "\"'\\\"\"", "\"(\"", "\"-\"", "\"Array\"", "\"Bool\"", "\"Dyn\"", "\"Number\"", "\"String\"", "\"[\"", "\"[|\"", "\"_\"", "\"array/at\"", "\"array/generate\"", "\"array/length\"", "\"array/map\"", "\"array/slice\"", "\"bin num literal\"", "\"blame\"", "\"contract/apply\"", "\"contract/array_lazy_app\"", "\"contract/record_lazy_app\"", "\"dec num literal\"", "\"deep_seq\"", "\"deserialize\"", "\"enum/embed\"", "\"enum/from_string\"", "\"enum/get_arg\"", "\"enum/get_tag\"", "\"enum/is_variant\"", "\"enum/make_variant\"", "\"eval_nix\"", "\"false\"", "\"forall\"", "\"hash\"", "\"hex num literal\"", "\"identifier\"", "\"label/append_note\"", "\"label/flip_polarity\"", "\"label/go_array\"", "\"label/go_codom\"", "\"label/go_dict\"", "\"label/go_dom\"", "\"label/go_field\"", "\"label/insert_type_variable\"", "\"label/lookup_type_variable\"", "\"label/polarity\"", "\"label/push_diag\"", "\"label/with_message\"", "\"label/with_notes\"", "\"m%\\\"\"", "\"match\"", "\"null\"", "\"number/from_string\"", "\"oct num literal\"", "\"op force\"", "\"op rec_default\"", "\"op rec_force\"", "\"or\"", "\"pow\"", "\"raw enum tag\"", "\"record/empty_with_tail\"", "\"record/field_is_defined\"", "\"record/field_is_defined_with_opts\"", "\"record/fields\"", "\"record/fields_with_opts\"", "\"record/has_field\"", "\"record/has_field_with_opts\"", "\"record/insert\"", "\"record/insert_with_opts\"", "\"record/map\"", "\"record/remove\"", "\"record/remove_with_opts\"", "\"record/seal_tail\"", "\"record/unseal_tail\"", "\"record/values\"", "\"seal\"", "\"seq\"", "\"serialize\"", "\"string/chars\"", "\"string/contains\"", "\"string/find\"", "\"string/find_all\"", "\"string/is_match\"", "\"string/length\"", "\"string/lowercase\"", "\"string/replace\"", "\"string/replace_regex\"", "\"string/split\"", "\"string/substr\"", "\"string/trim\"", "\"string/uppercase\"", "\"symbolic string start\"", "\"to_string\"", "\"trace\"", "\"true\"", "\"typeof\"", "\"unseal\"", "\"{\""])] }, Original(RawSpan { src_id: FileId(2), start: ByteIndex(0), end: ByteIndex(16) })))
domenkozar commented 1 month ago

Thanks!

@yannham how about this:

[2024-10-17T17:03:14Z ERROR topiary] Error parsing query file
[2024-10-17T17:03:14Z ERROR topiary] Cause: QueryError { row: 40, column: 4, offset: 866, message: "    \"(\" @append_spaced_softline @append_indent_start\n    ^", kind: Structure }
yannham commented 1 month ago

It's strange. It seems that the formals node isn't recognized for some reason, or not expected here (If I replace the offending line with formals: (_ then it works, or rather this precise error disappears) but looking at the tree-sitter Nix grammar this should be valid at first sight. I need to run right now but I'll give it a second look tomorrow.

domenkozar commented 1 month ago

Alright it does run now, but it needs work on the formatting.