aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-09-29 22:21:57 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-09-29 22:21:57 +0200
commitfe1bee80a175a25ba5de9fb7fe63429436ee8af2 (patch)
treec5723139524c2c5fd0e0d449e379a22d735a0cff
parent632a1ca20e713430bdcfe6bca60ebf269f260c69 (diff)
parent0f20cb93208f3f1505ee5d1844f8df427006e9f5 (diff)
Merge branch 'master' of https://github.com/DanielGavin/ols
-rw-r--r--builtin/builtin.odin27
-rw-r--r--editors/vscode/syntaxes/odin.tmLanguage.json42
-rw-r--r--src/odin/printer/printer.odin13
-rw-r--r--src/server/completion.odin2
4 files changed, 74 insertions, 10 deletions
diff --git a/builtin/builtin.odin b/builtin/builtin.odin
index b370cbc..bdd3f5b 100644
--- a/builtin/builtin.odin
+++ b/builtin/builtin.odin
@@ -75,8 +75,14 @@ Odin_Arch_Type :: enum int {
}
@builtin
+ODIN_OS_STRING: string
+
+@builtin
ODIN_ARCH: Odin_Arch_Type
+@builtin
+ODIN_ARCH_STRING: string
+
Odin_Build_Mode_Type :: enum int {
Executable,
Dynamic,
@@ -111,6 +117,9 @@ Odin_Platform_Subtarget_Type :: enum int {
}
@builtin
+ODIN_ENDIAN_STRING: string
+
+@builtin
ODIN_PLATFORM_SUBTARGET: Odin_Platform_Subtarget_Type
Odin_Sanitizer_Flag :: enum u32 {
@@ -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 b1190a4..c47b964 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": [
@@ -511,10 +545,6 @@
"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 8fb8baf..74f5853 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 1b7249d..c085881 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",