diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2025-02-08 20:24:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-08 20:24:25 +0100 |
| commit | e170595126b2642a8e01d93f7a0e4987a4db9c2b (patch) | |
| tree | 73d4e4c2ce4d9e2153d50bffa55899a4b496fe5e | |
| parent | a27ef1f954a581cefed4a85f8f438d6c42821dce (diff) | |
| parent | e1cafb6bb11dd6b2b89231ee8241b188a904cf06 (diff) | |
Merge branch 'master' into spaces_around_colon
| -rw-r--r-- | misc/odinfmt.schema.json | 7 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/misc/odinfmt.schema.json b/misc/odinfmt.schema.json index e650851..7984da9 100644 --- a/misc/odinfmt.schema.json +++ b/misc/odinfmt.schema.json @@ -56,10 +56,17 @@ "default": false, "description": "When statement in the clause contains one simple statement, it will inline the case and statement in one line" }, + "spaces_around_colons": { "type": "boolean", "default": false, "description": "Put a space on both sides of a single colon during variable/field declaration, such as `foo : bar`" + }, + + "sort_imports": { + "type": "boolean", + "default": true, + "description": "Sorts imports alphabetically" } }, "required": [] diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 4304019..a58a0de 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -243,7 +243,13 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) -> ^Do } document = cons(document, text("}")) } else if len(v.fullpaths) == 1 { - document = cons_with_nopl(document, visit_expr(p, v.fullpaths[0])) + if _, ok := v.fullpaths[0].derived_expr.(^ast.Basic_Lit); ok { + document = cons_with_nopl(document, visit_expr(p, v.fullpaths[0])) + } else { + document = cons_with_nopl(document, text("{")) + document = cons(document, visit_expr(p, v.fullpaths[0])) + document = cons(document, text("}")) + } } return document |