From bc55f5beea4ddd64ce4a2996d64095e145f26cfc Mon Sep 17 00:00:00 2001 From: Daniel Gavin Date: Sun, 28 Nov 2021 16:43:50 +0100 Subject: Add formatter to ols --- src/server/format.odin | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/server/format.odin') 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; -- cgit v1.2.3