diff --git a/builtin/builtin.odin b/builtin/builtin.odin index b370cbcd..bdd3f5b0 100644 --- a/builtin/builtin.odin +++ b/builtin/builtin.odin @@ -74,9 +74,15 @@ Odin_Arch_Type :: enum int { wasm64p32, } +@builtin +ODIN_OS_STRING: string + @builtin ODIN_ARCH: Odin_Arch_Type +@builtin +ODIN_ARCH_STRING: string + Odin_Build_Mode_Type :: enum int { Executable, Dynamic, @@ -110,6 +116,9 @@ Odin_Platform_Subtarget_Type :: enum int { iOS, } +@builtin +ODIN_ENDIAN_STRING: string + @builtin ODIN_PLATFORM_SUBTARGET: Odin_Platform_Subtarget_Type @@ -168,3 +177,21 @@ ODIN_NO_RTTI: bool @builtin ODIN_COMPILE_TIMESTAMP: int + +@builtin +ODIN_NO_DYNAMIC_LITERALS: bool + +@builtin +ODIN_USE_SEPARATE_MODULES: bool + +@builtin +ODIN_TEST: bool + +@builtin +ODIN_FOREIGN_ERROR_PROCEDURES: bool + +@builtin +ODIN_BUILD_PROJECT_NAME: string + +@builtin +ODIN_VALGRIND_SUPPORT: bool diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index b1190a45..c47b964b 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -79,6 +79,7 @@ "expressions": { "patterns": [ { "include": "#comments" }, + { "include": "#ternary" }, { "include": "#map-bitset" }, { "include": "#slice" }, { "include": "#keywords" }, @@ -86,6 +87,8 @@ { "include": "#basic-types" }, { "include": "#procedure-calls" }, { "include": "#property-access" }, + { "include": "#union-member-access" }, + { "include": "#union-non-nil-access" }, { "include": "#strings" }, { "include": "#punctuation" }, { "include": "#variable-name" } @@ -355,20 +358,51 @@ } ] }, + "ternary": { + "name": "meta.ternary.odin", + "begin": "\\?", + "beginCaptures": { "0": { "name": "keyword.operator.ternary.odin" } }, + "end": ":", + "endCaptures": { "0": { "name": "keyword.operator.ternary.odin" } }, + "patterns": [{ "include": "#expressions" }] + }, "slice": { "name": "meta.slice.odin", "begin": "\\[", "beginCaptures": { "0": { "name": "meta.brace.square.odin" } }, "end": "\\]", "endCaptures": { "0": { "name": "meta.brace.square.odin" } }, - "patterns": [ { "include": "#expressions" } ] + "patterns": [ + { "match": "\\?", "name": "keyword.operator.array.odin" }, + { "match": ":", "name": "keyword.operator.slice.odin" }, + { "include": "#expressions" } + ] }, "property-access": { + "match": "([A-Za-z_]\\w*)\\s*(\\.)\\s*(?=[A-Za-z_]\\w*)", "captures": { "1": { "name": "variable.other.object.odin" }, "2": { "name": "punctuation.accessor.odin" } + } + }, + "union-member-access": { + "begin": "([A-Za-z_]\\w*)\\s*(\\.)\\s*(\\()", + "beginCaptures": { + "1": { "name": "variable.other.object.odin" }, + "2": { "name": "punctuation.accessor.odin" }, + "3": { "name": "meta.brace.round.odin" } }, - "match": "([A-Za-z_]\\w*)\\s*(\\.)(?=\\s*[A-Za-z_]\\w*)" + "end": "\\)", + "endCaptures": {"0": { "name": "meta.brace.round.odin" }}, + "patterns": [{ "include": "#type-declaration" }] + }, + "union-non-nil-access": { + "match": "([A-Za-z_]\\w*)\\s*(\\.)\\s*(\\?)", + "captures": { + "1": { "name": "variable.other.object.odin" }, + "2": { "name": "punctuation.accessor.odin" }, + "3": { "name": "punctuation.accessor.optional.odin" } + } }, "comments": { "patterns": [ @@ -510,10 +544,6 @@ "match": "->", "name": "storage.type.function.arrow.odin" }, - { - "name": "keyword.operator.ternary.odin", - "match": "\\?" - }, { "name": "keyword.operator.odin", "match": "@|(\\||\\!|:|\\+|-|\\*|/|%|\\<\\\\>?|\\~)=?|=|: : ?|\\$" diff --git a/src/odin/printer/printer.odin b/src/odin/printer/printer.odin index 8fb8baf6..74f5853c 100644 --- a/src/odin/printer/printer.odin +++ b/src/odin/printer/printer.odin @@ -129,13 +129,18 @@ build_disabled_lines_info :: proc(p: ^Printer) { for group in p.comments { for comment in group.list { - comment_text, _ := strings.replace_all(comment.text[:], " ", "", context.temp_allocator) - if strings.contains(comment_text, "//odinfmt:disable") { + if !strings.starts_with(comment.text, "//") do continue + comment_text := strings.trim_left_space(comment.text[len("//"):]) + + if !strings.starts_with(comment_text, "odinfmt:") do continue + action := strings.trim_space(comment_text[len("odinfmt:"):]) + + if action == "disable" { found_disable = true empty = true disable_position = comment.pos - } else if strings.contains(comment_text, "//odinfmt:enable") && found_disable { + } else if found_disable && action == "enable" { begin := disable_position.offset - (comment.pos.column - 1) end := comment.pos.offset + len(comment.text) @@ -146,7 +151,7 @@ build_disabled_lines_info :: proc(p: ^Printer) { empty = empty, } - for line := disable_position.line; line <= comment.pos.line; line += 1 { + for line in disable_position.line..=comment.pos.line { p.disabled_lines[line] = disabled_info } diff --git a/src/server/completion.odin b/src/server/completion.odin index 1b7249d0..c0858815 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -178,8 +178,10 @@ DIRECTIVE_NAME_LIST :: []string { "line", "procedure", "caller_location", + "reverse", /* call directives */ "location", + "caller_expression", "exists", "load", "load_directory",