From c01c4b0e9b92fbcfb17f459a89a7fa3de14f1eff Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sat, 20 Jan 2024 22:13:36 +0100 Subject: Align bitsets in comp literals. --- src/odin/printer/visit.odin | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index e7bdda9..a153df5 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1438,7 +1438,7 @@ should_align_comp_lit :: proc(p: ^Printer, comp_lit: ast.Comp_Lit) -> bool { } @(private) -comp_lit_contains_fields :: proc(p: ^Printer, comp_lit: ast.Comp_Lit) -> bool { +comp_lit_contains_fields :: proc(comp_lit: ast.Comp_Lit) -> bool { if len(comp_lit.elems) == 0 { return false @@ -2051,7 +2051,7 @@ visit_expr :: proc( } should_newline := - comp_lit_contains_fields(p, v^) || + comp_lit_contains_fields(v^) || contains_comments_in_range(p, v.pos, v.end) should_newline &= (called_from == .Value_Decl || @@ -2807,8 +2807,10 @@ get_possible_comp_lit_alignment :: proc(exprs: []^ast.Expr) -> int { return 0 } - if _, is_comp := value.value.derived.(^ast.Comp_Lit); is_comp { - return 0 + if comp, is_comp := value.value.derived.(^ast.Comp_Lit); is_comp { + if comp_lit_contains_fields(comp^) { + return 0 + } } longest_name = max(longest_name, get_node_length(value.field)) -- cgit v1.2.3 From 795f8d5718afeee6bb06b28bcce091719336326f Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Tue, 23 Jan 2024 19:36:56 +0100 Subject: Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index fe2a049..5094826 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,7 @@ Example of `ols.json`: { "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json", "collections": [ - { "name": "core", "path": "c:/path/to/Odin/core" }, - { "name": "shared", "path": "c:/path/to/MyProject/src" } + { "name": "custom_collection", "path": "c:/path/to/collection" }, ], "enable_semantic_tokens": false, "enable_document_symbols": true, -- cgit v1.2.3 From e536b9393c64c1fe61d87b46dcdfa45bc1c1efcf Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Tue, 23 Jan 2024 19:37:17 +0100 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5094826..98e7553 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ Configuration of the LSP: { "name": "collection_a", "path": "/path/to/collection_a" - }, + } ], "enable_semantic_tokens": true, "enable_document_symbols": true, -- cgit v1.2.3 From 594b43a7e0b642473733aabd103ec9830fb1e926 Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Wed, 24 Jan 2024 23:20:23 +0100 Subject: Remove where-clause from syntax --- editors/vscode/syntaxes/odin.tmLanguage.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index a78f23e..b0090c7 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -15,10 +15,9 @@ { "include": "#constant-assignment" }, { "include": "#variable-assignment" }, { "include": "#case-clause" }, - { "include": "#where-clause" }, { "include": "#block-label" }, { "include": "#type-annotation" }, - { "include": "#block-declaration" }, + { "include": "#block-definition" }, { "include": "#expressions" } ] }, @@ -114,7 +113,15 @@ "end": "(?=^|,|;|\\)|=|:|for|switch|if|{)", "patterns": [ { "include": "#type-declaration" } ] }, - "block-declaration": { + "object-definition": { + "name": "meta.object.type.odin", + "begin": "\\{", + "beginCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, + "end": "\\}", + "endCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, + "patterns": [ { "include": "#statements" } ] + }, + "block-definition": { "name": "meta.block.odin", "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, @@ -141,13 +148,13 @@ "patterns": [ { "include": "#parameters" }, { "include": "#return-type-declaration" }, - { "include": "#where-clause" }, - { "include": "#type-declaration" } + { "include": "#object-definition" }, + { "include": "#expressions" } ] }, { "include": "#comments" }, { "include": "#strings" }, - { "include": "#block-declaration" }, + { "include": "#block-definition" }, { "include": "#keywords" }, { "include": "#basic-types" }, { "include": "#slice" }, @@ -223,13 +230,6 @@ { "include": "#type-declaration" } ] }, - "where-clause": { - "name": "meta.where.clause.odin", - "begin": "\\bwhere\\b", - "beginCaptures": { "0": { "name": "keyword.other.where.odin" } }, - "end": "(?={)", - "patterns": [ { "include": "#expressions" } ] - }, "case-clause": { "name": "meta.case-clause.expr.odin", "begin": "case", -- cgit v1.2.3 From 0dfd887bec02efb4eda374495c79791fb5d76215 Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Wed, 24 Jan 2024 23:45:21 +0100 Subject: Add enable_format option to ols.schema.json and readme --- README.md | 6 ++++-- misc/ols.schema.json | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98e7553..4438706 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ cd ols In order for the language server to index your files, it must know about your collections. -To do that you can either configure ols via an ``ols.json`` file (it should be located at the root of your workspace). +To do that you can either configure ols via an `ols.json` file (it should be located at the root of your workspace). Or you can provide the configuration via your editor of choice. @@ -43,7 +43,7 @@ Example of `ols.json`: { "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json", "collections": [ - { "name": "custom_collection", "path": "c:/path/to/collection" }, + { "name": "custom_collection", "path": "c:/path/to/collection" } ], "enable_semantic_tokens": false, "enable_document_symbols": true, @@ -56,6 +56,8 @@ You can also set `ODIN_ROOT` environment variable to the path where ols should l Options: +`enable_format`: Turns on formatting with `odinfmt`. _(Enabled by default)_ + `enable_hover`: Enables hover feature `enable_snippets`: Turns on builtin snippets diff --git a/misc/ols.schema.json b/misc/ols.schema.json index bc01704..a374681 100644 --- a/misc/ols.schema.json +++ b/misc/ols.schema.json @@ -21,6 +21,11 @@ "type": "boolean", "description": "Turns on outline of all your global declarations in your document." }, + "enable_format": { + "type": "boolean", + "description": "Turns on formatting with odinfmt.", + "default": true + }, "enable_hover": { "type": "boolean", "description": "Enables hover feature" -- cgit v1.2.3