aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-08-17 13:26:20 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-08-17 13:26:20 +0200
commit4820ffdf3e5567aa645561964b769f6a8e6f86aa (patch)
tree3fb751ec66fbaf1abd6094ca4e5bbfb287528cb5
parent49ef89a0cabc93c31b115a00de16e799dd87abce (diff)
enable hover on default, if not specified in config
-rw-r--r--README.md6
-rw-r--r--src/server/requests.odin6
-rw-r--r--src/server/types.odin5
-rw-r--r--src/server/unmarshal.odin22
4 files changed, 24 insertions, 15 deletions
diff --git a/README.md b/README.md
index 945a8b3..15192dd 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,9 @@ Options:
`enable_snippets`: Turns on builtin snippets
-`enable_semantic_tokens`: Turn on syntax highlighting, and is only supported on few editors. It is also cause of many crashes.
+`enable_semantic_tokens`: Turns on syntax highlighting.
+
+`enable_document_symbols`: Turns on outline of all your global declarations in your document.
`odin_command`: Allows you to specifiy your Odin location, instead of just relying on the environment path.
@@ -81,7 +83,7 @@ Options:
`tabs`: Tabs or spaces.
-`tabs_width`: The many characters one tab represents
+`tabs_width`: How many characters one tab represents
## Features
Support Language server features:
diff --git a/src/server/requests.odin b/src/server/requests.odin
index 430a258..cd2677f 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -388,9 +388,8 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C
if unmarshal(value, ols_config, context.temp_allocator) == nil {
config.thread_count = ols_config.thread_pool_count
- config.enable_document_symbols = ols_config.enable_document_symbols
- config.enable_hover = ols_config.enable_hover
- config.enable_format = true // ols_config.enable_format;
+ config.enable_document_symbols = ols_config.enable_document_symbols.(bool) or_else true
+ config.enable_hover = ols_config.enable_hover.(bool) or_else true
config.enable_semantic_tokens = ols_config.enable_semantic_tokens
config.enable_procedure_context = ols_config.enable_procedure_context
config.enable_snippets = ols_config.enable_snippets
@@ -400,6 +399,7 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C
config.odin_command = strings.clone(ols_config.odin_command, context.allocator)
config.checker_args = strings.clone(ols_config.checker_args, context.allocator)
config.enable_inlay_hints = ols_config.enable_inlay_hints
+ config.enable_format = true
for p in ols_config.collections {
forward_path, _ := filepath.to_slash(p.path, context.temp_allocator)
diff --git a/src/server/types.odin b/src/server/types.odin
index d3e3dbc..dcc741a 100644
--- a/src/server/types.odin
+++ b/src/server/types.odin
@@ -321,9 +321,8 @@ OlsConfig :: struct {
collections: [dynamic]OlsConfigCollection,
thread_pool_count: int,
enable_semantic_tokens: bool,
- enable_document_symbols: bool,
- enable_hover: bool,
- enable_format: bool,
+ enable_document_symbols: Maybe(bool),
+ enable_hover: Maybe(bool),
enable_procedure_context: bool,
enable_snippets: bool,
enable_inlay_hints: bool,
diff --git a/src/server/unmarshal.odin b/src/server/unmarshal.odin
index 3910115..7aba429 100644
--- a/src/server/unmarshal.odin
+++ b/src/server/unmarshal.odin
@@ -46,10 +46,6 @@ unmarshal :: proc(json_value: json.Value, v: any, allocator: mem.Allocator) -> j
}
case Type_Info_Union:
-
- //Note(Daniel, THIS IS REALLY SCUFFED. Need to talk to gingerbill about unmarshalling unions)
-
- //This only works for unions with one object - made to handle optionals
tag_ptr := uintptr(v.data) + variant.tag_offset
tag_any := any {rawptr(tag_ptr), variant.tag_type.id}
@@ -145,9 +141,21 @@ unmarshal :: proc(json_value: json.Value, v: any, allocator: mem.Allocator) -> j
}
case json.Null:
case json.Boolean:
- if _, ok := type_info.variant.(Type_Info_Boolean); ok {
- tmp := bool(j)
- mem.copy(v.data, &tmp, type_info.size)
+ #partial switch variant in &type_info.variant {
+ case Type_Info_Boolean:
+ tmp := bool(j)
+ mem.copy(v.data, &tmp, type_info.size)
+ case Type_Info_Union:
+ tag_ptr := uintptr(v.data) + variant.tag_offset
+ tag_any := any {rawptr(tag_ptr), variant.tag_type.id}
+
+ not_optional := 1
+
+ mem.copy(cast(rawptr)tag_ptr, &not_optional, size_of(variant.tag_type))
+
+ id := variant.variants[0].id
+
+ unmarshal(json_value, any {v.data, id}, allocator)
}
case:
return .Unsupported_Type