diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-03-10 21:54:28 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-03-10 21:54:28 +0100 |
| commit | 89fd8a66c987703801288300a78376cdf140c198 (patch) | |
| tree | d5b73fcc631f6af1942935f7ac9fd9b2c4ed48b1 /src/server | |
| parent | e86f46836c66a3c55dbf321fa58c95a7bd237414 (diff) | |
Add fallback in `odin check` to try all directory with odin code in them.
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/check.odin | 43 | ||||
| -rw-r--r-- | src/server/requests.odin | 12 |
2 files changed, 45 insertions, 10 deletions
diff --git a/src/server/check.odin b/src/server/check.odin index d041320..a3804df 100644 --- a/src/server/check.odin +++ b/src/server/check.odin @@ -21,7 +21,50 @@ import "src:common" //Store uris we have reported on since last save. We use this to clear them on next save. uris_reported := make([dynamic]string) + +//If the user does not specify where to call odin check, it'll just find all directory with odin, and call them seperately. +fallback_find_odin_directories :: proc(config: ^common.Config) -> []string { + walk_proc :: proc( + info: os.File_Info, + in_err: os.Errno, + user_data: rawptr, + ) -> ( + err: os.Errno, + skip_dir: bool, + ) { + data := cast(^[dynamic]string)user_data + + if !info.is_dir && filepath.ext(info.name) == ".odin" { + dir := filepath.dir(info.fullpath, context.temp_allocator) + if !slice.contains(data[:], dir) { + append(data, dir) + } + } + + return in_err, false + } + + data := make([dynamic]string, context.temp_allocator) + + if len(config.workspace_folders) > 0 { + if uri, ok := common.parse_uri( + config.workspace_folders[0].uri, + context.temp_allocator, + ); ok { + filepath.walk(uri.path, walk_proc, &data) + } + } + + return data[:] +} + check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) { + paths := paths + + if len(paths) == 0 { + paths = fallback_find_odin_directories(config) + } + data := make([]byte, mem.Kilobyte * 200, context.temp_allocator) buffer: []byte diff --git a/src/server/requests.odin b/src/server/requests.odin index a877c69..00b649b 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -695,6 +695,7 @@ request_initialize :: proc( ) } + for format in initialize_params.capabilities.textDocument.hover.contentFormat { if format == "markdown" { config.hover_support_md = true @@ -1180,16 +1181,7 @@ notification_did_save :: proc( log.errorf("failed to collect symbols on save %v", ret) } - if len(config.profile.checker_path) > 0 { - check(config.profile.checker_path[:], writer, config) - } else { - if uri, ok := common.parse_uri( - config.workspace_folders[0].uri, - context.temp_allocator, - ); ok { - check({uri.path}, writer, config) - } - } + check(config.profile.checker_path[:], writer, config) return .None } |