Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DanielGavin/ols
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Sep 29, 2024
2 parents 632a1ca + 0f20cb9 commit fe1bee8
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
27 changes: 27 additions & 0 deletions builtin/builtin.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -110,6 +116,9 @@ Odin_Platform_Subtarget_Type :: enum int {
iOS,
}

@builtin
ODIN_ENDIAN_STRING: string

@builtin
ODIN_PLATFORM_SUBTARGET: Odin_Platform_Subtarget_Type

Expand Down Expand Up @@ -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
42 changes: 36 additions & 6 deletions editors/vscode/syntaxes/odin.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@
"expressions": {
"patterns": [
{ "include": "#comments" },
{ "include": "#ternary" },
{ "include": "#map-bitset" },
{ "include": "#slice" },
{ "include": "#keywords" },
{ "include": "#type-parameter" },
{ "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" }
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -510,10 +544,6 @@
"match": "->",
"name": "storage.type.function.arrow.odin"
},
{
"name": "keyword.operator.ternary.odin",
"match": "\\?"
},
{
"name": "keyword.operator.odin",
"match": "@|(\\||\\!|:|\\+|-|\\*|/|%|\\<\\<?|\\>\\>?|\\~)=?|=|: : ?|\\$"
Expand Down
13 changes: 9 additions & 4 deletions src/odin/printer/printer.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions src/server/completion.odin
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ DIRECTIVE_NAME_LIST :: []string {
"line",
"procedure",
"caller_location",
"reverse",
/* call directives */
"location",
"caller_expression",
"exists",
"load",
"load_directory",
Expand Down

0 comments on commit fe1bee8

Please sign in to comment.