aboutsummaryrefslogtreecommitdiff
path: root/src/server/workspace_symbols.odin
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-12-30 22:20:28 +0100
committerDanielGavin <danielgavin5@hotmail.com>2024-12-30 22:20:28 +0100
commitf53599650dc10ebd9a5cd85313ffff4b7b319be3 (patch)
tree3f6e0362d8dc957d033e0c1a04a55812f420cec6 /src/server/workspace_symbols.odin
parentfded19fc8ede748d31b67686941fbe33a8f77214 (diff)
Add exclude path for workspace symbols.
Diffstat (limited to 'src/server/workspace_symbols.odin')
-rw-r--r--src/server/workspace_symbols.odin58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/server/workspace_symbols.odin b/src/server/workspace_symbols.odin
index cf2f435..2d0f2f1 100644
--- a/src/server/workspace_symbols.odin
+++ b/src/server/workspace_symbols.odin
@@ -5,34 +5,32 @@ import "core:fmt"
import "core:log"
import "core:os"
import "core:path/filepath"
+import "core:strings"
import "src:common"
+dir_blacklist :: []string{"node_modules", ".git"}
+
@(private)
-walk_dir :: proc(
- info: os.File_Info,
- in_err: os.Errno,
- user_data: rawptr,
-) -> (
- err: os.Error,
- skip_dir: bool,
-) {
+walk_dir :: proc(info: os.File_Info, in_err: os.Errno, user_data: rawptr) -> (err: os.Error, skip_dir: bool) {
pkgs := cast(^[dynamic]string)user_data
if info.is_dir {
dir, _ := filepath.to_slash(info.fullpath, context.temp_allocator)
+ dir_name := filepath.base(dir)
+
+ for blacklist in dir_blacklist {
+ if blacklist == dir_name {
+ return nil, true
+ }
+ }
append(pkgs, dir)
}
return nil, false
}
-get_workspace_symbols :: proc(
- query: string,
-) -> (
- workspace_symbols: []WorkspaceSymbol,
- ok: bool,
-) {
+get_workspace_symbols :: proc(query: string) -> (workspace_symbols: []WorkspaceSymbol, ok: bool) {
workspace := common.config.workspace_folders[0]
uri := common.parse_uri(workspace.uri, context.temp_allocator) or_return
pkgs := make([dynamic]string, 0, context.temp_allocator)
@@ -40,26 +38,40 @@ get_workspace_symbols :: proc(
filepath.walk(uri.path, walk_dir, &pkgs)
- for pkg in pkgs {
- matches, err := filepath.glob(
- fmt.tprintf("%v/*.odin", pkg),
- context.temp_allocator,
- )
+ log.error(pkgs)
+
+ _pkg: for pkg in pkgs {
+ matches, err := filepath.glob(fmt.tprintf("%v/*.odin", pkg), context.temp_allocator)
if len(matches) == 0 {
continue
}
+ for exclude_path in common.config.profile.exclude_path {
+ exclude_forward, _ := filepath.to_slash(exclude_path, context.temp_allocator)
+
+ if exclude_forward[len(exclude_forward) - 2:] == "**" {
+ lower_pkg := strings.to_lower(pkg)
+ lower_exclude := strings.to_lower(exclude_forward[:len(exclude_forward) - 3])
+ if strings.contains(lower_pkg, lower_exclude) {
+ continue _pkg
+ }
+ } else {
+ lower_pkg := strings.to_lower(pkg)
+ lower_exclude := strings.to_lower(exclude_forward)
+ if lower_pkg == lower_exclude {
+ continue _pkg
+ }
+ }
+ }
+
try_build_package(pkg)
if results, ok := fuzzy_search(query, {pkg}); ok {
for result in results {
symbol := WorkspaceSymbol {
name = result.symbol.name,
- location = {
- range = result.symbol.range,
- uri = result.symbol.uri,
- },
+ location = {range = result.symbol.range, uri = result.symbol.uri},
kind = symbol_kind_to_type(result.symbol.type),
}