diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/format.odin | 11 | ||||
| -rw-r--r-- | src/server/requests.odin | 15 | ||||
| -rw-r--r-- | src/server/types.odin | 4 |
3 files changed, 23 insertions, 7 deletions
diff --git a/src/server/format.odin b/src/server/format.odin index 82857dc..6eb83de 100644 --- a/src/server/format.odin +++ b/src/server/format.odin @@ -2,7 +2,7 @@ package server import "shared:common" -import "core:odin/printer" +import "shared:odin/printer" FormattingOptions :: struct { tabSize: uint, @@ -22,8 +22,13 @@ TextEdit :: struct { newText: string, } -get_complete_format :: proc(document: ^common.Document) -> ([]TextEdit, bool) { - prnt := printer.make_printer(printer.default_style, context.temp_allocator); +get_complete_format :: proc(document: ^common.Document, config: ^common.Config) -> ([]TextEdit, bool) { + + style := printer.default_style; + style.max_characters = config.formatter.characters; + style.tabs = config.formatter.tabs; + + prnt := printer.make_printer(style, context.temp_allocator); if document.ast.syntax_error_count > 0 { return {}, true; diff --git a/src/server/requests.odin b/src/server/requests.odin index 1d48887..f78053e 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -399,17 +399,24 @@ request_initialize :: proc (task: ^common.Task) { if value, err := json.parse(data = data, allocator = context.temp_allocator, parse_integers = true); err == .None { - ols_config: OlsConfig; + ols_config := OlsConfig { + formatter = { + characters = 90, + tabs = true, + }, + } if unmarshal(value, ols_config, context.temp_allocator) == .None { config.thread_count = ols_config.thread_pool_count; config.enable_document_symbols = ols_config.enable_document_symbols; config.enable_hover = ols_config.enable_hover; - config.enable_format = ols_config.enable_format; + config.enable_format = true // ols_config.enable_format; config.enable_semantic_tokens = ols_config.enable_semantic_tokens; config.enable_procedure_context = ols_config.enable_procedure_context; config.verbose = ols_config.verbose; + config.file_log = ols_config.file_log; + config.formatter = ols_config.formatter; for p in ols_config.collections { @@ -723,7 +730,7 @@ request_format_document :: proc (task: ^common.Task) { } edit: []TextEdit; - edit, ok = get_complete_format(document); + edit, ok = get_complete_format(document, config); if !ok { handle_error(.InternalError, id, writer); @@ -913,6 +920,8 @@ notification_did_save :: proc (task: ^common.Task) { if ret := index.collect_symbols(&index.indexer.dynamic_index.collection, file, uri.uri); ret != .None { log.errorf("failed to collect symbols on save %v", ret); } + + check(uri, writer); } request_semantic_token_full :: proc (task: ^common.Task) { diff --git a/src/server/types.odin b/src/server/types.odin index 03da6f4..53a54b7 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -269,6 +269,8 @@ OlsConfig :: struct { enable_format: bool, enable_procedure_context: bool, verbose: bool, + file_log: bool, + formatter: common.Format_Config, } OlsConfigCollection :: struct { @@ -327,4 +329,4 @@ Command :: struct { title: string, command: string, arguments: []string, -} +}
\ No newline at end of file |