diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2020-11-27 01:36:39 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2020-11-27 01:36:39 +0100 |
| commit | a4a54cedcaf53beb40fc087b26f0f1ec31b6574f (patch) | |
| tree | 4396d0a2add8c02bfba7c7b4cb12b15aa145f2c8 /src/server | |
| parent | 1af0f32800032022f7addbe5ce706a6f13767aba (diff) | |
add support for json configuration in the workspace
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/requests.odin | 39 | ||||
| -rw-r--r-- | src/server/types.odin | 9 |
2 files changed, 46 insertions, 2 deletions
diff --git a/src/server/requests.odin b/src/server/requests.odin index abcb59e..c84a3bd 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -8,9 +8,11 @@ import "core:strings" import "core:slice" import "core:strconv" import "core:encoding/json" +import "core:path" -import "shared:common" +import "shared:common" +import "shared:index" Header :: struct { content_length: int, @@ -219,7 +221,32 @@ request_initialize :: proc(params: json.Value, id: RequestId, config: ^common.Co config.workspace_folders = make([dynamic]common.WorkspaceFolder); for s in initialize_params.workspaceFolders { - append_elem(&config.workspace_folders, s); + append(&config.workspace_folders, s); + } + + //right now just look at the first workspace - TODO(daniel, add multiple workspace support) + if uri, ok := common.parse_uri(config.workspace_folders[0].uri, context.temp_allocator); ok { + + ols_config_path := path.join(elems = {uri.path, "ols.json"}, allocator = context.temp_allocator); + + if data, ok := os.read_entire_file(ols_config_path, context.temp_allocator); ok { + + if value, err := json.parse(data = data, allocator = context.temp_allocator, parse_integers = true); err == .None { + + ols_config: OlsConfig; + + if unmarshal(value, ols_config, context.temp_allocator) == .None { + + for p in ols_config.collections { + config.collections[strings.clone(p.name)] = strings.clone(strings.to_lower(p.path, context.temp_allocator)); + } + + } + + } + + } + } for format in initialize_params.capabilities.textDocument.hover.contentFormat { @@ -254,6 +281,14 @@ request_initialize :: proc(params: json.Value, id: RequestId, config: ^common.Co id = id, ); + /* + Temp index here, but should be some background thread that starts the indexing + */ + + index.build_static_index(context.allocator, config); + + log.info("Finished indexing"); + send_response(response, writer); return .None; diff --git a/src/server/types.odin b/src/server/types.odin index d957041..e22d0ad 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -252,4 +252,13 @@ SignatureInformation :: struct { ParameterInformation :: struct { label: [2] int, +}; + +OlsConfig :: struct { + collections: [dynamic] OlsConfigCollection, +}; + +OlsConfigCollection :: struct { + name: string, + path: string, };
\ No newline at end of file |