From 74ea70325e4daca321a0932828f236ea8c77f2ec Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Tue, 26 Aug 2025 10:18:49 -0400 Subject: Add option to disable document links --- README.md | 2 ++ builtin/builtin.odin | 2 +- misc/ols.schema.json | 5 +++++ odinfmt.json | 2 +- odinfmt.sh | 2 +- src/common/config.odin | 1 + src/server/requests.odin | 10 ++++++++++ src/server/types.odin | 1 + 8 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 205979e..608cf97 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Options: `enable_completion_matching`: Attempt to match types and pointers when passing arguments to procedures. _(Enabled by default)_ +`enable_document_links`: Follow links when opening documentation. This is usually done via `` and will open the documentation in a browser (or similar). _(Enabled by default)_ + `odin_command`: Specify the location to your Odin executable, rather than relying on the environment path. `odin_root_override`: Allows you to specify a custom `ODIN_ROOT` that `ols` will use to look for `odin` core libraries when implementing custom runtimes. diff --git a/builtin/builtin.odin b/builtin/builtin.odin index e13b6fd..f342ff9 100644 --- a/builtin/builtin.odin +++ b/builtin/builtin.odin @@ -351,7 +351,7 @@ ODIN_VERSION: string Empty if `.git` could not be detected at the time the compiler was built. */ @builtin -ODIN_VERSION_HASH:string +ODIN_VERSION_HASH: string @builtin Odin_Windows_Subsystem_Type :: enum int { diff --git a/misc/ols.schema.json b/misc/ols.schema.json index 3ec252d..3bd2489 100644 --- a/misc/ols.schema.json +++ b/misc/ols.schema.json @@ -80,6 +80,11 @@ "description": "Turn on fake methods completion.", "default": false }, + "enable_document_links": { + "type": "boolean", + "description": "Follow links when opening documentation.", + "default": true + }, "disable_parser_errors": { "type": "boolean" }, "verbose": { "type": "boolean", diff --git a/odinfmt.json b/odinfmt.json index d3f7daa..6910b06 100644 --- a/odinfmt.json +++ b/odinfmt.json @@ -2,4 +2,4 @@ "character_width": 120, "tabs": true, "tabs_width": 4 -} \ No newline at end of file +} diff --git a/odinfmt.sh b/odinfmt.sh index 449d8b4..838c9e3 100755 --- a/odinfmt.sh +++ b/odinfmt.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -odin build tools/odinfmt/main.odin -file -show-timings -collection:src=src -out:odinfmt -o:speed +odin build tools/odinfmt/main.odin -file -show-timings -collection:src=src -out:odinfmt -o:none diff --git a/src/common/config.odin b/src/common/config.odin index e45e2b6..5b2923c 100644 --- a/src/common/config.odin +++ b/src/common/config.odin @@ -35,6 +35,7 @@ Config :: struct { enable_checker_only_saved: bool, enable_auto_import: bool, enable_completion_matching: bool, + enable_document_links: bool, disable_parser_errors: bool, thread_count: int, file_log: bool, diff --git a/src/server/requests.odin b/src/server/requests.odin index c564a31..4f090d8 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -367,6 +367,7 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi config.enable_references = ols_config.enable_references.(bool) or_else config.enable_references config.enable_completion_matching = ols_config.enable_completion_matching.(bool) or_else config.enable_completion_matching + config.enable_document_links = ols_config.enable_document_links.(bool) or_else config.enable_document_links config.verbose = ols_config.verbose.(bool) or_else config.verbose config.file_log = ols_config.file_log.(bool) or_else config.file_log @@ -615,6 +616,7 @@ request_initialize :: proc( config.enable_snippets = false config.enable_references = true config.enable_completion_matching = true + config.enable_document_links = true config.verbose = false config.file_log = false config.odin_command = "" @@ -1335,6 +1337,14 @@ request_document_links :: proc( config: ^common.Config, writer: ^Writer, ) -> common.Error { + if !config.enable_document_links { + links: []DocumentLink + response := make_response_message(params = links, id = id) + + send_response(response, writer) + return .None + } + params_object, ok := params.(json.Object) if !ok { diff --git a/src/server/types.odin b/src/server/types.odin index 4795f11..e13ae31 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -413,6 +413,7 @@ OlsConfig :: struct { enable_inlay_hints_params: Maybe(bool), enable_inlay_hints_default_params: Maybe(bool), enable_references: Maybe(bool), + enable_document_links: Maybe(bool), enable_fake_methods: Maybe(bool), enable_procedure_snippet: Maybe(bool), enable_checker_only_saved: Maybe(bool), -- cgit v1.2.3