diff options
| author | moonz <pmnarimani@gmail.com> | 2026-01-27 10:13:05 +0100 |
|---|---|---|
| committer | moonz <pmnarimani@gmail.com> | 2026-01-27 10:13:05 +0100 |
| commit | aa993b9b366c79b978fb0901fdd75295f9cc0426 (patch) | |
| tree | c53cf0ea039699ad78e237b96d7eb882960369f0 | |
| parent | 396f4b887e6d7fe50957dce2a7c06199a07b670e (diff) | |
| parent | a243fa37d7735dc8777d445d2d3c9965f92f9c02 (diff) | |
Merge branch 'master' into overload_resolution
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | misc/ols.schema.json | 5 | ||||
| -rw-r--r-- | src/common/config.odin | 79 | ||||
| -rw-r--r-- | src/server/requests.odin | 2 | ||||
| -rw-r--r-- | src/server/signature.odin | 36 | ||||
| -rw-r--r-- | src/server/types.odin | 67 |
6 files changed, 108 insertions, 83 deletions
@@ -105,6 +105,8 @@ Options: - `enable_comp_lit_signature_help`: Provide signature help for comp lits such as when instantiating structs. Will not display correctly on some editors such as vscode. +- `enable_comp_lit_signature_help_use_docs`: Put signature help for comp lits in the documentation. This will allow it to be rendered nicely using markdown in editors that render the label without colour on one line. + - `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/misc/ols.schema.json b/misc/ols.schema.json index 4c9e447..81bc0cd 100644 --- a/misc/ols.schema.json +++ b/misc/ols.schema.json @@ -102,6 +102,11 @@ "description": "Provide signature help for comp lits such as when instantiating structs. Will not display correctly on some editors such as vscode.", "default": false }, + "enable_comp_lit_signature_help_use_docs": { + "type": "boolean", + "description": "Put signature help for comp lits in the documentation. This will allow it to be rendered nicely using markdown in editors that render the label without colour on one line.", + "default": false + }, "disable_parser_errors": { "type": "boolean" }, "verbose": { "type": "boolean", diff --git a/src/common/config.odin b/src/common/config.odin index a1f2400..f2ae68f 100644 --- a/src/common/config.odin +++ b/src/common/config.odin @@ -10,45 +10,46 @@ ConfigProfile :: struct { } Config :: struct { - workspace_folders: [dynamic]WorkspaceFolder, - completion_support_md: bool, - hover_support_md: bool, - signature_offset_support: bool, - collections: map[string]string, - running: bool, - verbose: bool, - enable_format: bool, - enable_hover: bool, - enable_document_symbols: bool, - enable_semantic_tokens: bool, - enable_unused_imports_reporting: bool, - enable_inlay_hints_params: bool, - enable_inlay_hints_default_params: bool, - enable_inlay_hints_implicit_return: bool, - enable_procedure_context: bool, - enable_snippets: bool, - enable_references: bool, - enable_document_highlights: bool, - enable_label_details: bool, - enable_std_references: bool, - enable_import_fixer: bool, - enable_fake_method: bool, - enable_overload_resolution: bool, - enable_procedure_snippet: bool, - enable_checker_only_saved: bool, - enable_auto_import: bool, - enable_completion_matching: bool, - enable_document_links: bool, - enable_comp_lit_signature_help: bool, - disable_parser_errors: bool, - thread_count: int, - file_log: bool, - odin_command: string, - odin_root_override: string, - checker_args: string, - checker_targets: []string, - client_name: string, - profile: ConfigProfile, + workspace_folders: [dynamic]WorkspaceFolder, + completion_support_md: bool, + hover_support_md: bool, + signature_offset_support: bool, + collections: map[string]string, + running: bool, + verbose: bool, + enable_format: bool, + enable_hover: bool, + enable_document_symbols: bool, + enable_semantic_tokens: bool, + enable_unused_imports_reporting: bool, + enable_inlay_hints_params: bool, + enable_inlay_hints_default_params: bool, + enable_inlay_hints_implicit_return: bool, + enable_procedure_context: bool, + enable_snippets: bool, + enable_references: bool, + enable_document_highlights: bool, + enable_label_details: bool, + enable_std_references: bool, + enable_import_fixer: bool, + enable_fake_method: bool, + enable_overload_resolution: bool, + enable_procedure_snippet: bool, + enable_checker_only_saved: bool, + enable_auto_import: bool, + enable_completion_matching: bool, + enable_document_links: bool, + enable_comp_lit_signature_help: bool, + enable_comp_lit_signature_help_use_docs: bool, + disable_parser_errors: bool, + thread_count: int, + file_log: bool, + odin_command: string, + odin_root_override: string, + checker_args: string, + checker_targets: []string, + client_name: string, + profile: ConfigProfile, } config: Config diff --git a/src/server/requests.odin b/src/server/requests.odin index 0a1d089..64142ed 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -376,6 +376,8 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi config.enable_document_links = ols_config.enable_document_links.(bool) or_else config.enable_document_links config.enable_comp_lit_signature_help = ols_config.enable_comp_lit_signature_help.(bool) or_else config.enable_comp_lit_signature_help + config.enable_comp_lit_signature_help_use_docs = + ols_config.enable_comp_lit_signature_help_use_docs.(bool) or_else config.enable_comp_lit_signature_help_use_docs config.verbose = ols_config.verbose.(bool) or_else config.verbose config.file_log = ols_config.file_log.(bool) or_else config.file_log diff --git a/src/server/signature.odin b/src/server/signature.odin index f6c79fc..a53c084 100644 --- a/src/server/signature.odin +++ b/src/server/signature.odin @@ -1,5 +1,6 @@ package server +import "core:fmt" import "core:log" import "core:odin/ast" import "core:odin/tokenizer" @@ -30,7 +31,7 @@ SignatureHelp :: struct { SignatureInformation :: struct { label: string, - documentation: string, + documentation: MarkupContent, parameters: []ParameterInformation, } @@ -105,14 +106,21 @@ get_signature_information :: proc( if config.enable_comp_lit_signature_help { if symbol, ok := resolve_comp_literal(&ast_context, &position_context); ok { - build_documentation(&ast_context, &symbol, short_signature = false) - append( - &signature_information, - SignatureInformation { - label = get_signature(symbol), - documentation = construct_symbol_docs(symbol), - }, - ) + if config.enable_comp_lit_signature_help_use_docs { + build_documentation(&ast_context, &symbol, short_signature = true) + signature := get_signature(symbol) + build_documentation(&ast_context, &symbol, short_signature = false) + append( + &signature_information, + SignatureInformation{label = signature, documentation = write_hover_content(&ast_context, symbol)}, + ) + } else { + build_documentation(&ast_context, &symbol, short_signature = false) + append( + &signature_information, + SignatureInformation{label = get_signature(symbol), documentation = write_markdown_doc(symbol)}, + ) + } } } @@ -176,7 +184,7 @@ add_proc_signature :: proc( info := SignatureInformation { label = get_signature(call), - documentation = construct_symbol_docs(call), + documentation = write_markdown_doc(call), parameters = parameters, } append(signature_information, info) @@ -204,7 +212,7 @@ add_proc_signature :: proc( info := SignatureInformation { label = get_signature(symbol), - documentation = construct_symbol_docs(symbol), + documentation = write_markdown_doc(symbol), parameters = parameters, } @@ -214,3 +222,9 @@ add_proc_signature :: proc( } return active_parameter } + +@(private = "file") +write_markdown_doc :: proc(symbol: Symbol) -> MarkupContent { + doc := construct_symbol_docs(symbol) + return MarkupContent{kind = "markdown", value = fmt.tprintf(DOC_FMT_ODIN, doc)} +} diff --git a/src/server/types.odin b/src/server/types.odin index 0d57b6f..c65e181 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -277,10 +277,10 @@ DiagnosticSeverity :: enum { Hint = 4, } - DiagnosticTag :: enum int { +DiagnosticTag :: enum int { Unnecessary = 1, Deprecated = 2, - } +} Diagnostic :: struct { range: common.Range, @@ -413,37 +413,38 @@ FileSystemWatcher :: struct { } OlsConfig :: struct { - collections: [dynamic]OlsConfigCollection, - thread_pool_count: Maybe(int), - enable_format: Maybe(bool), - enable_hover: Maybe(bool), - enable_document_symbols: Maybe(bool), - enable_fake_methods: Maybe(bool), - enable_overload_resolution: Maybe(bool), - enable_references: Maybe(bool), - enable_document_highlights: Maybe(bool), - enable_document_links: Maybe(bool), - enable_comp_lit_signature_help: Maybe(bool), - enable_completion_matching: Maybe(bool), - enable_inlay_hints_params: Maybe(bool), - enable_inlay_hints_default_params: Maybe(bool), - enable_inlay_hints_implicit_return: Maybe(bool), - enable_semantic_tokens: Maybe(bool), - enable_unused_imports_reporting: Maybe(bool), - enable_procedure_context: Maybe(bool), - enable_snippets: Maybe(bool), - enable_procedure_snippet: Maybe(bool), - enable_checker_only_saved: Maybe(bool), - enable_auto_import: Maybe(bool), - disable_parser_errors: Maybe(bool), - verbose: Maybe(bool), - file_log: Maybe(bool), - odin_command: string, - odin_root_override: string, - checker_args: string, - checker_targets: []string, - profiles: [dynamic]common.ConfigProfile, - profile: string, + collections: [dynamic]OlsConfigCollection, + thread_pool_count: Maybe(int), + enable_format: Maybe(bool), + enable_hover: Maybe(bool), + enable_document_symbols: Maybe(bool), + enable_fake_methods: Maybe(bool), + enable_overload_resolution: Maybe(bool), + enable_references: Maybe(bool), + enable_document_highlights: Maybe(bool), + enable_document_links: Maybe(bool), + enable_comp_lit_signature_help: Maybe(bool), + enable_comp_lit_signature_help_use_docs: Maybe(bool), + enable_completion_matching: Maybe(bool), + enable_inlay_hints_params: Maybe(bool), + enable_inlay_hints_default_params: Maybe(bool), + enable_inlay_hints_implicit_return: Maybe(bool), + enable_semantic_tokens: Maybe(bool), + enable_unused_imports_reporting: Maybe(bool), + enable_procedure_context: Maybe(bool), + enable_snippets: Maybe(bool), + enable_procedure_snippet: Maybe(bool), + enable_checker_only_saved: Maybe(bool), + enable_auto_import: Maybe(bool), + disable_parser_errors: Maybe(bool), + verbose: Maybe(bool), + file_log: Maybe(bool), + odin_command: string, + odin_root_override: string, + checker_args: string, + checker_targets: []string, + profiles: [dynamic]common.ConfigProfile, + profile: string, } OlsConfigCollection :: struct { |