aboutsummaryrefslogtreecommitdiff
path: root/src/server
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
parentfded19fc8ede748d31b67686941fbe33a8f77214 (diff)
Add exclude path for workspace symbols.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/build.odin8
-rw-r--r--src/server/completion.odin1
-rw-r--r--src/server/memory_index.odin2
-rw-r--r--src/server/requests.odin14
-rw-r--r--src/server/workspace_symbols.odin58
5 files changed, 50 insertions, 33 deletions
diff --git a/src/server/build.odin b/src/server/build.odin
index a46a577..e3478ae 100644
--- a/src/server/build.odin
+++ b/src/server/build.odin
@@ -172,7 +172,13 @@ setup_index :: proc() {
dir_exe := common.get_executable_path(context.temp_allocator)
- try_build_package(path.join({dir_exe, "builtin"}, context.temp_allocator))
+ builtin_path := path.join({dir_exe, "builtin"}, context.temp_allocator)
+
+ if !os.exists(builtin_path) {
+ log.error("Failed to find the builtin folder at %v", builtin_path)
+ }
+
+ try_build_package(builtin_path)
}
free_index :: proc() {
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 706fe07..75d0d64 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -1443,6 +1443,7 @@ get_identifier_completion :: proc(
insertText = result.snippet.insert,
kind = .Snippet,
detail = result.snippet.detail,
+ documentation = result.doc,
insertTextFormat = .Snippet,
}
diff --git a/src/server/memory_index.odin b/src/server/memory_index.odin
index f2b48f7..0e660de 100644
--- a/src/server/memory_index.odin
+++ b/src/server/memory_index.odin
@@ -45,7 +45,7 @@ memory_index_fuzzy_search :: proc(index: ^MemoryIndex, name: string, pkgs: []str
fuzzy_matcher := common.make_fuzzy_matcher(name)
- top := 20
+ top := 100
for pkg in pkgs {
if pkg, ok := index.collection.packages[pkg]; ok {
diff --git a/src/server/requests.odin b/src/server/requests.odin
index 9de82b6..d9581ee 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -399,15 +399,13 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi
for profile in ols_config.profiles {
if ols_config.profile == profile.name {
config.profile.checker_path = make([dynamic]string, len(profile.checker_path))
+ config.profile.exclude_path = make([dynamic]string, len(profile.exclude_path))
- if filepath.is_abs(ols_config.profile) {
- for checker_path, i in profile.checker_path {
- config.profile.checker_path[i] = strings.clone(checker_path)
- }
- } else {
- for checker_path, i in profile.checker_path {
- config.profile.checker_path[i] = path.join(elems = {uri.path, checker_path})
- }
+ for checker_path, i in profile.checker_path {
+ config.profile.checker_path[i] = path.join(elems = {uri.path, checker_path})
+ }
+ for exclude_path, i in profile.exclude_path {
+ config.profile.exclude_path[i] = path.join(elems = {uri.path, exclude_path})
}
config.profile.os = strings.clone(profile.os)
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),
}