diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-06-28 23:54:10 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-06-28 23:54:10 +0200 |
| commit | 28f666c77352734ee720b3b56e34f7261d3a86b2 (patch) | |
| tree | b90802760959cae5d80004a874d3df5011a6c2f6 /src | |
| parent | f2dd4753508299f86490c083cf4eaad0c8ab7b1e (diff) | |
| parent | 9fc36bfa5c76bec6f890d744398169a8069ada5a (diff) | |
Merge branch 'master' into rename
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/visit.odin | 7 | ||||
| -rw-r--r-- | src/server/build.odin | 37 | ||||
| -rw-r--r-- | src/server/completion.odin | 60 | ||||
| -rw-r--r-- | src/server/requests.odin | 17 |
4 files changed, 108 insertions, 13 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index cbf63ed..9407ec8 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -327,6 +327,13 @@ visit_decl :: proc( case ^Import_Decl: document := move_line(p, decl.pos) + if len(v.attributes) > 0 { + document = cons( + document, + visit_attributes(p, &v.attributes, v.pos), + ) + } + if v.name.text != "" { document = cons( document, diff --git a/src/server/build.odin b/src/server/build.odin index f06f64e..312cb00 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -27,6 +27,9 @@ platform_os: map[string]bool = { "openbsd" = true, "wasi" = true, "wasm" = true, + "haiku" = true, + "netbsd" = true, + "freebsd" = true, } @@ -39,8 +42,28 @@ os_enum_to_string: map[runtime.Odin_OS_Type]string = { .WASI = "wasi", .JS = "js", .Freestanding = "freestanding", - .OpenBSD = "openbsd", .JS = "wasm", + .Haiku = "haiku", + .OpenBSD = "openbsd", + .NetBSD = "netbsd", + .FreeBSD = "freebsd", +} + +@(private = "file") +is_bsd_variant :: proc(name: string) -> bool { + return( + common.config.profile.os == os_enum_to_string[.FreeBSD] || + common.config.profile.os == os_enum_to_string[.OpenBSD] || + common.config.profile.os == os_enum_to_string[.NetBSD] \ + ) +} + +@(private = "file") +is_unix_variant :: proc(name: string) -> bool { + return( + common.config.profile.os == os_enum_to_string[.Linux] || + common.config.profile.os == os_enum_to_string[.Darwin] \ + ) } skip_file :: proc(filename: string) -> bool { @@ -50,10 +73,16 @@ skip_file :: proc(filename: string) -> bool { if last_underscore_index + 1 < last_dot_index { name_between := filename[last_underscore_index + 1:last_dot_index] + if name_between == "unix" { + return !is_unix_variant(name_between) + } + + if name_between == "bsd" { + return !is_bsd_variant(name_between) + } + if _, ok := platform_os[name_between]; ok { - if name_between != os_enum_to_string[ODIN_OS] { - return true - } + return name_between != common.config.profile.os } } diff --git a/src/server/completion.odin b/src/server/completion.odin index a863d5c..42bec3e 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1999,6 +1999,66 @@ append_magic_dynamic_array_completion :: proc( append(items, item) } + // This proc is shared between slices and dynamic arrays. + if _, ok := symbol.value.(SymbolDynamicArrayValue); !ok { + return + } + + prefix := "&" + suffix := "" + if symbol.pointers > 0 { + prefix = "" + suffix = common.repeat( + "^", + symbol.pointers - 1, + context.temp_allocator, + ) + } + ptr_symbol_str := fmt.tprint(prefix, symbol_str, suffix, sep = "") + + //pop + { + item := CompletionItem { + label = "pop", + kind = .Function, + detail = "pop", + textEdit = TextEdit { + newText = fmt.tprintf("pop(%v)", ptr_symbol_str), + range = {start = range.end, end = range.end}, + }, + additionalTextEdits = additionalTextEdits, + } + + append(items, item) + } + + dynamic_array_builtins := []string { + "append", + "unordered_remove", + "ordered_remove", + "resize", + "reserve", + "shrink", + "inject_at", + "assign_at", + } + + for name in dynamic_array_builtins { + item := CompletionItem { + label = name, + kind = .Snippet, + detail = name, + additionalTextEdits = additionalTextEdits, + textEdit = TextEdit { + newText = fmt.tprintf("%s(%v, $0)", name, ptr_symbol_str), + range = {start = range.end, end = range.end}, + }, + insertTextFormat = .Snippet, + InsertTextMode = .adjustIndentation, + } + + append(items, item) + } } append_magic_union_completion :: proc( diff --git a/src/server/requests.odin b/src/server/requests.odin index 3d0991f..b47c4a0 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -478,23 +478,22 @@ read_ols_initialize_options :: proc( ) } } + + config.profile.os = strings.clone(profile.os) + + break } } + if config.profile.os == "" { + config.profile.os = os_enum_to_string[ODIN_OS] + } + config.checker_targets = slice.clone( ols_config.checker_targets, context.allocator, ) - found_target := false - - for target in config.checker_targets { - if ODIN_OS in os_enum_to_string { - found_target = true - } - } - - config.enable_inlay_hints = ols_config.enable_inlay_hints.(bool) or_else config.enable_inlay_hints config.enable_fake_method = |