diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2023-11-25 15:35:30 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2023-11-25 15:35:30 +0100 |
| commit | 31cda7e3b038d982b063fb6ff29d8f19fc3b23ac (patch) | |
| tree | 443e60e8f0ec8a501c0f565f909adb7157c7d545 /src | |
| parent | 6bcf5f9cf49622e8f1bd488a1d2c3a357f834a32 (diff) | |
Add new config for "enable_procedure_snippet"
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/config.odin | 2 | ||||
| -rw-r--r-- | src/server/check.odin | 38 | ||||
| -rw-r--r-- | src/server/completion.odin | 8 | ||||
| -rw-r--r-- | src/server/requests.odin | 32 | ||||
| -rw-r--r-- | src/server/types.odin | 2 |
5 files changed, 54 insertions, 28 deletions
diff --git a/src/common/config.odin b/src/common/config.odin index 673805b..71a6f4e 100644 --- a/src/common/config.odin +++ b/src/common/config.odin @@ -21,11 +21,13 @@ Config :: struct { enable_std_references: bool, enable_import_fixer: bool, enable_fake_method: bool, + enable_procedure_snippet: bool, disable_parser_errors: bool, thread_count: int, file_log: bool, odin_command: string, checker_args: string, + checker_targets: []string, client_name: string, } diff --git a/src/server/check.odin b/src/server/check.odin index 6ede069..502beb5 100644 --- a/src/server/check.odin +++ b/src/server/check.odin @@ -1,20 +1,20 @@ package server +import "core:encoding/json" import "core:fmt" +import "core:intrinsics" import "core:log" import "core:mem" import "core:os" -import "core:strings" -import "core:slice" -import "core:strconv" -import "core:encoding/json" +import "core:path/filepath" import path "core:path/slashpath" import "core:runtime" -import "core:thread" +import "core:slice" +import "core:strconv" +import "core:strings" import "core:sync" -import "core:path/filepath" -import "core:intrinsics" import "core:text/scanner" +import "core:thread" import "shared:common" @@ -46,16 +46,16 @@ check :: proc(uri: common.Uri, writer: ^Writer, config: ^common.Config) { } if code, ok, buffer = common.run_executable( - fmt.tprintf( - "%v check %s %s -no-entry-point %s %s", - command, - path.dir(uri.path, context.temp_allocator), - strings.to_string(collection_builder), - config.checker_args, - ODIN_OS == .Linux || ODIN_OS == .Darwin ? "2>&1" : "", - ), - &data, - ); !ok { + fmt.tprintf( + "%v check %s %s -no-entry-point %s %s", + command, + path.dir(uri.path, context.temp_allocator), + strings.to_string(collection_builder), + config.checker_args, + ODIN_OS == .Linux || ODIN_OS == .Darwin ? "2>&1" : "", + ), + &data, + ); !ok { log.errorf( "Odin check failed with code %v for file %v", code, @@ -195,10 +195,10 @@ check :: proc(uri: common.Uri, writer: ^Writer, config: ^common.Config) { append( &errors[error.uri], - Diagnostic{ + Diagnostic { code = "checker", severity = .Error, - range = { + range = { start = {character = error.column, line = error.line - 1}, end = {character = 0, line = error.line}, }, diff --git a/src/server/completion.odin b/src/server/completion.odin index 94789e2..0aebf50 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -613,7 +613,9 @@ get_selector_completion :: proc( documentation = symbol.doc, } - if symbol.type == .Function && common.config.enable_snippets { + if symbol.type == .Function && + common.config.enable_snippets && + common.config.enable_procedure_snippet { item.insertText = fmt.tprintf("%v($0)", item.label) item.insertTextFormat = .Snippet item.command = Command { @@ -1376,7 +1378,9 @@ get_identifier_completion :: proc( item.kind = symbol_type_to_completion_kind(result.type) - if result.type == .Function && common.config.enable_snippets { + if result.type == .Function && + common.config.enable_snippets && + common.config.enable_procedure_snippet { item.insertText = fmt.tprintf("%v($0)", item.label) item.insertTextFormat = .Snippet item.deprecated = .Deprecated in result.flags diff --git a/src/server/requests.odin b/src/server/requests.odin index 7ce5fc2..cdd2702 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -426,6 +426,9 @@ read_ols_initialize_options :: proc( config.enable_rename = ols_config.enable_references.(bool) or_else config.enable_rename + config.enable_procedure_snippet = + ols_config.enable_procedure_snippet.(bool) or_else config.enable_procedure_snippet + if ols_config.odin_command != "" { config.odin_command = strings.clone( ols_config.odin_command, @@ -440,6 +443,20 @@ read_ols_initialize_options :: proc( ) } + config.checker_targets = slice.clone( + ols_config.checker_targets, + context.allocator, + ) + + found_target := false + + for target in config.checker_targets { + if ODIN_OS in os_enum_to_string { + found_target = true + } + } + + config.enable_inlay_hints = ols_config.enable_inlay_hints.(bool) or_else config.enable_inlay_hints config.enable_fake_method = @@ -582,6 +599,7 @@ request_initialize :: proc( config.checker_args = "" config.enable_inlay_hints = false config.enable_fake_method = false + config.enable_procedure_snippet = true read_ols_config :: proc( file: string, @@ -684,9 +702,9 @@ request_initialize :: proc( } response := make_response_message( - params = ResponseInitializeParams{ - capabilities = ServerCapabilities{ - textDocumentSync = TextDocumentSyncOptions{ + params = ResponseInitializeParams { + capabilities = ServerCapabilities { + textDocumentSync = TextDocumentSyncOptions { openClose = true, change = 2, save = {includeText = true}, @@ -695,19 +713,19 @@ request_initialize :: proc( workspaceSymbolProvider = true, referencesProvider = config.enable_references, definitionProvider = true, - completionProvider = CompletionOptions{ + completionProvider = CompletionOptions { resolveProvider = false, triggerCharacters = completionTriggerCharacters, completionItem = {labelDetailsSupport = true}, }, - signatureHelpProvider = SignatureHelpOptions{ + signatureHelpProvider = SignatureHelpOptions { triggerCharacters = signatureTriggerCharacters, retriggerCharacters = signatureRetriggerCharacters, }, - semanticTokensProvider = SemanticTokensOptions{ + semanticTokensProvider = SemanticTokensOptions { range = config.enable_semantic_tokens, full = config.enable_semantic_tokens, - legend = SemanticTokensLegend{ + legend = SemanticTokensLegend { tokenTypes = token_types, tokenModifiers = token_modifiers, }, diff --git a/src/server/types.odin b/src/server/types.odin index f809bf8..3903c73 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -347,11 +347,13 @@ OlsConfig :: struct { enable_inlay_hints: Maybe(bool), enable_references: Maybe(bool), enable_fake_methods: Maybe(bool), + enable_procedure_snippet: Maybe(bool), disable_parser_errors: Maybe(bool), verbose: Maybe(bool), file_log: Maybe(bool), odin_command: string, checker_args: string, + checker_targets: []string, } OlsConfigCollection :: struct { |