diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-02-03 12:57:07 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-02-03 12:57:07 +0100 |
| commit | 690a94a64c354eac808e07c6077b2f92b8dfcb88 (patch) | |
| tree | 064c1145045842db1edb1d22afd02b4b66a1d87e /src/server | |
| parent | 7c9bfc7bbfa05cace89efc39c946bd90229dba2d (diff) | |
| parent | bb0773ba7ead80b14781095ea39a9a8a83aa6d03 (diff) | |
Merge branch 'master' into poly
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/completion.odin | 30 | ||||
| -rw-r--r-- | src/server/requests.odin | 17 |
2 files changed, 39 insertions, 8 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 36db067..4bb0430 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -675,6 +675,14 @@ get_selector_completion :: proc( selector, &items, ) + case SymbolSliceValue: + list.isIncomplete = false + append_magic_dynamic_array_completion( + position_context, + selector, + &items, + ) + case SymbolMapValue: list.isIncomplete = false append_magic_map_completion(position_context, selector, &items) @@ -1732,7 +1740,7 @@ append_magic_map_completion :: proc( additionalTextEdits := make([]TextEdit, 1, context.temp_allocator) additionalTextEdits[0] = remove_edit - + symbol_str := get_expression_string_from_position_context(position_context) //for { item := CompletionItem { @@ -1743,7 +1751,7 @@ append_magic_map_completion :: proc( textEdit = TextEdit { newText = fmt.tprintf( "for ${{1:k}}, ${{2:v}} in %v {{\n\t$0 \n}}", - symbol.name, + symbol_str, ), range = {start = range.end, end = range.end}, }, @@ -1754,7 +1762,17 @@ append_magic_map_completion :: proc( append(items, item) } } - +get_expression_string_from_position_context :: proc(position_context: ^DocumentPositionContext) -> string { + src := position_context.file.src + if position_context.call != nil { + return src[position_context.call.pos.offset:position_context.call.end.offset] + } else if position_context.field != nil { + return src[position_context.field.pos.offset:position_context.field.end.offset] + } else if position_context.selector != nil { + return src[position_context.selector.pos.offset:position_context.selector.end.offset] + } + return "" +} append_magic_dynamic_array_completion :: proc( position_context: ^DocumentPositionContext, symbol: Symbol, @@ -1779,9 +1797,11 @@ append_magic_dynamic_array_completion :: proc( additionalTextEdits := make([]TextEdit, 1, context.temp_allocator) additionalTextEdits[0] = remove_edit + symbol_str := get_expression_string_from_position_context(position_context) + //len { - text := fmt.tprintf("len(%v)", symbol.name) + text := fmt.tprintf("len(%v)", symbol_str) item := CompletionItem { label = "len", @@ -1807,7 +1827,7 @@ append_magic_dynamic_array_completion :: proc( textEdit = TextEdit { newText = fmt.tprintf( "for i in %v {{\n\t$0 \n}}", - symbol.name, + symbol_str, ), range = {start = range.end, end = range.end}, }, diff --git a/src/server/requests.odin b/src/server/requests.odin index cdd2702..4c653ad 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -10,7 +10,6 @@ import "core:odin/parser" import "core:os" import "core:path/filepath" import path "core:path/slashpath" -import "core:runtime" import "core:slice" import "core:strconv" import "core:strings" @@ -20,6 +19,7 @@ import "core:time" import "shared:common" +import "base:runtime" Header :: struct { content_length: int, @@ -551,6 +551,17 @@ read_ols_initialize_options :: proc( allocator = context.allocator, ) } + + if "base" not_in config.collections && odin_core_env != "" { + forward_path, _ := filepath.to_slash( + odin_core_env, + context.temp_allocator, + ) + config.collections[strings.clone("base")] = path.join( + elems = {forward_path, "base"}, + allocator = context.allocator, + ) + } } request_initialize :: proc( @@ -1077,8 +1088,8 @@ notification_did_save :: proc( fullpath := uri.path p := parser.Parser { - err = log_error_handler, - warn = log_warning_handler, + err = log_error_handler, + warn = log_warning_handler, flags = {.Optional_Semicolons}, } |