aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-10-29 16:42:38 -0400
committerGitHub <noreply@github.com>2025-10-29 16:42:38 -0400
commit9854c3ec2786498c94a341183c6b901af375826a (patch)
tree376ba69bd1b6ae688b2d307be615945dd50bb816 /src
parent9a5240c22fe9bd84e216be76989b50f120157cf3 (diff)
parent69d6b1d88b61c3f4d73d05c398272fc692853262 (diff)
Merge pull request #1126 from doongjohn/master
Fix read_ols_initialize_options order and collection overriding.
Diffstat (limited to 'src')
-rw-r--r--src/server/requests.odin93
1 files changed, 55 insertions, 38 deletions
diff --git a/src/server/requests.odin b/src/server/requests.odin
index a775850..82d0ae2 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -444,13 +444,24 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi
config.enable_fake_method = ols_config.enable_fake_methods.(bool) or_else config.enable_fake_method
-
+ // Delete overriding collections.
for it in ols_config.collections {
- if it.name in config.collections {
- delete(config.collections[it.name])
- delete_key(&config.collections, it.name)
+ overrides := make([dynamic]string)
+ defer delete(overrides)
+ for k, v in config.collections {
+ if it.name == k {
+ append(&overrides, k)
+ }
}
+ for k in overrides {
+ delete(config.collections[k])
+ delete_key(&config.collections, k)
+ delete(k)
+ }
+ }
+ // Apply custom collections.
+ for it in ols_config.collections {
forward_path, _ := filepath.to_slash(it.path, context.temp_allocator)
forward_path = common.resolve_home_dir(forward_path, context.temp_allocator)
@@ -531,46 +542,52 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi
}
}
- if abs_core_env, ok := filepath.abs(odin_core_env, context.temp_allocator); ok {
- odin_core_env = abs_core_env
+ if odin_core_env != "" {
+ if abs_core_env, ok := filepath.abs(odin_core_env, context.temp_allocator); ok {
+ odin_core_env = abs_core_env
+ }
}
}
}
log.infof("resolved odin root to: %q", odin_core_env)
- if "core" not_in config.collections && odin_core_env != "" {
+ // Insert the default collections if they are not specified in the config.
+ if odin_core_env != "" {
forward_path, _ := filepath.to_slash(odin_core_env, context.temp_allocator)
- config.collections[strings.clone("core")] = path.join(
- elems = {forward_path, "core"},
- allocator = context.allocator,
- )
- }
- if "vendor" not_in config.collections && odin_core_env != "" {
- forward_path, _ := filepath.to_slash(odin_core_env, context.temp_allocator)
- config.collections[strings.clone("vendor")] = path.join(
- elems = {forward_path, "vendor"},
- allocator = context.allocator,
- )
- }
+ // base
+ if "base" not_in config.collections {
+ config.collections[strings.clone("base")] = path.join(
+ elems = {forward_path, "base"},
+ 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,
- )
- }
+ // core
+ if "core" not_in config.collections {
+ config.collections[strings.clone("core")] = path.join(
+ elems = {forward_path, "core"},
+ allocator = context.allocator,
+ )
+ }
- if "shared" not_in config.collections && odin_core_env != "" {
- forward_path, _ := filepath.to_slash(odin_core_env, context.temp_allocator)
- shared_path := path.join(elems = {forward_path, "shared"}, allocator = context.allocator)
+ // vendor
+ if "vendor" not_in config.collections {
+ config.collections[strings.clone("vendor")] = path.join(
+ elems = {forward_path, "vendor"},
+ allocator = context.allocator,
+ )
+ }
- if os.exists(shared_path) {
- config.collections[strings.clone("shared")] = shared_path
- } else {
- delete(shared_path)
+ // shared
+ if "shared" not_in config.collections {
+ shared_path := path.join(elems = {forward_path, "shared"}, allocator = context.allocator)
+ if os.exists(shared_path) {
+ config.collections[strings.clone("shared")] = shared_path
+ } else {
+ delete(shared_path)
+ }
}
}
@@ -661,23 +678,23 @@ request_initialize :: proc(
}
if uri, ok := common.parse_uri(project_uri, context.temp_allocator); ok {
+ // Apply the global ols config.
global_ols_config_path := path.join(
elems = {filepath.dir(os.args[0], context.temp_allocator), "ols.json"},
allocator = context.temp_allocator,
)
-
read_ols_config(global_ols_config_path, config, uri)
- ols_config_path := path.join(elems = {uri.path, "ols.json"}, allocator = context.temp_allocator)
+ // Apply the requested ols config.
+ read_ols_initialize_options(config, initialize_params.initializationOptions, uri)
+ // Apply ols.json config.
+ ols_config_path := path.join(elems = {uri.path, "ols.json"}, allocator = context.temp_allocator)
read_ols_config(ols_config_path, config, uri)
-
- read_ols_initialize_options(config, initialize_params.initializationOptions, uri)
} else {
read_ols_initialize_options(config, initialize_params.initializationOptions, {})
}
-
for format in initialize_params.capabilities.textDocument.hover.contentFormat {
if format == "markdown" {
config.hover_support_md = true