aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-08-08 22:09:57 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-08-08 22:09:57 +0200
commitc9a3fba84d9645470b64f2174e56533fbe35c10a (patch)
treeac9508927b2164974f9fb57f8188d0a2aff5872c /src/server
parentb7b21f1b56a867a33a27bde0b24ef07d8761fea5 (diff)
add support to `odinfmt.json` config for formatter.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/format.odin18
-rw-r--r--src/server/requests.odin10
-rw-r--r--src/server/types.odin1
3 files changed, 7 insertions, 22 deletions
diff --git a/src/server/format.odin b/src/server/format.odin
index 57243ff..236bee2 100644
--- a/src/server/format.odin
+++ b/src/server/format.odin
@@ -2,6 +2,8 @@ package server
import "shared:common"
import "shared:odin/printer"
+import "shared:odin/format"
+import "core:path/filepath"
import "core:log"
@@ -19,19 +21,6 @@ DocumentFormattingParams :: struct {
}
get_complete_format :: proc(document: ^Document, config: ^common.Config) -> ([]TextEdit, bool) {
- style := printer.default_style
- style.tabs = config.formatter.tabs
-
- if config.formatter.characters != 0 {
- style.max_characters = config.formatter.characters
- }
-
- if config.formatter.spaces != 0 {
- style.spaces = config.formatter.spaces
- }
-
- prnt := printer.make_printer(style, context.temp_allocator)
-
if document.ast.syntax_error_count > 0 {
return {}, true
}
@@ -40,6 +29,9 @@ get_complete_format :: proc(document: ^Document, config: ^common.Config) -> ([]T
return {}, true
}
+ style := format.find_config_file_or_default(filepath.dir(document.fullpath, context.temp_allocator))
+ prnt := printer.make_printer(style, context.temp_allocator)
+
src := printer.print(&prnt, &document.ast)
log.error(src)
diff --git a/src/server/requests.odin b/src/server/requests.odin
index b7774d5..d89263b 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -384,13 +384,8 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C
read_ols_config :: proc(file: string, config: ^common.Config, uri: common.Uri) {
if data, ok := os.read_entire_file(file, context.temp_allocator); ok {
if value, err := json.parse(data = data, allocator = context.temp_allocator, parse_integers = true); err == .None {
- ols_config := OlsConfig {
- formatter = {
- characters = 90,
- tabs = true,
- },
- }
-
+ ols_config: OlsConfig
+
if unmarshal(value, ols_config, context.temp_allocator) == nil {
config.thread_count = ols_config.thread_pool_count
config.enable_document_symbols = ols_config.enable_document_symbols
@@ -402,7 +397,6 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C
config.enable_references = false
config.verbose = ols_config.verbose
config.file_log = ols_config.file_log
- config.formatter = ols_config.formatter
config.odin_command = strings.clone(ols_config.odin_command, context.allocator)
config.checker_args = ols_config.checker_args
config.enable_inlay_hints = ols_config.enable_inlay_hints
diff --git a/src/server/types.odin b/src/server/types.odin
index 78e7241..0c50ad5 100644
--- a/src/server/types.odin
+++ b/src/server/types.odin
@@ -329,7 +329,6 @@ OlsConfig :: struct {
enable_inlay_hints: bool,
verbose: bool,
file_log: bool,
- formatter: common.Format_Config,
odin_command: string,
checker_args: string,
}