Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Use PackageFromDir() for CompletionStore
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Jan 19, 2024
1 parent 6bfd28f commit f9fa75d
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions internal/lsp/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,11 @@ func InitCompletionStore(dirs []string) *CompletionStore {
}

for _, p := range pkgDirs {
files, err := ListGnoFiles(p)
pkg, err := PackageFromDir(p, false)
if err != nil {
// Ignore error
// Continue with rest of the packages
continue
}
symbols := []*Symbol{}
for _, file := range files {
symbols = append(symbols, getSymbols(file)...)
}
// convert to import path:
// get path relative to dir, and convert separators to slashes.
ip := strings.ReplaceAll(
strings.TrimPrefix(p, p+string(filepath.Separator)),
string(filepath.Separator), "/",
)

pkgs = append(pkgs, &Package{
Name: filepath.Base(p),
ImportPath: ip,
Symbols: symbols,
})
pkgs = append(pkgs, pkg)
}

return &CompletionStore{
Expand Down

0 comments on commit f9fa75d

Please sign in to comment.