diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-02-03 12:52:14 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-02-03 12:52:14 +0100 |
| commit | 7c9bfc7bbfa05cace89efc39c946bd90229dba2d (patch) | |
| tree | 496a1ce75b9f87613bd5420c477c809195c86785 | |
| parent | d3fd20e81162cbf3c41b4a7299d36ab56f72fae7 (diff) | |
| parent | d93559abe647e733b0338cf0707aba09c350481a (diff) | |
Merge branch 'master' into poly
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | editors/vscode/syntaxes/odin.tmLanguage.json | 26 | ||||
| -rw-r--r-- | misc/ols.schema.json | 5 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 10 |
4 files changed, 29 insertions, 21 deletions
@@ -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,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, @@ -57,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 @@ -143,7 +144,7 @@ Configuration of the LSP: { "name": "collection_a", "path": "/path/to/collection_a" - }, + } ], "enable_semantic_tokens": true, "enable_document_symbols": true, 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", 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" 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)) |