aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-06-22 00:08:21 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-06-22 00:08:21 +0200
commitb0e274b53936eac2c751d3d04a7b1bcd432cfe91 (patch)
treed3f38cf2527370f2561b62d6eef20dd4c2036ecf
parent0ff1e12ce89cf5d97625a73d1240b352e32400f2 (diff)
Use the default values if not specified in json
-rw-r--r--src/server/format.odin10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/server/format.odin b/src/server/format.odin
index 3cf8de6..0035545 100644
--- a/src/server/format.odin
+++ b/src/server/format.odin
@@ -19,10 +19,16 @@ DocumentFormattingParams :: struct {
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
- style.spaces = config.formatter.spaces
+ if characters, ok := config.formatter.characters.(int); ok {
+ style.max_characters = characters
+ }
+
+ if spaces, ok := config.formatter.spaces.(int); ok {
+ style.spaces = spaces
+ }
+
prnt := printer.make_printer(style, context.temp_allocator)
if document.ast.syntax_error_count > 0 {