Skip to content

[LSP] Reuse configured source discovery for workspace component indexing #739

Description

@cssbruno

Priority

Medium-high — editor correctness, module awareness, and consistency with CLI validation.

Context

internal/lsp/components.go builds workspace component definitions by walking the workspace root directly:

_ = filepath.WalkDir(root, func(filePath string, entry os.DirEntry, err error) error {
    ...
    if !strings.HasSuffix(filePath, ".gwdk") { return nil }
    payload, err := os.ReadFile(filePath)
    ...
    if lang.ClassifySource(filePath, payload) != lang.FileKindComponent { return nil }
    ...
})

The skip list is hard-coded to directory names such as .git, .gowdk, bin, dist, gowdk_cache, node_modules, and vendor.

Problem

The LSP workspace component index does not appear to use the same discovery rules as project-aware CLI commands.

Consequences:

  1. Components excluded by Source.Exclude can still appear in editor navigation/completion.
  2. Module-scoped source selection is not reflected in LSP component lookup.
  3. Hard-coded directory skips can drift from CLI discovery defaults.
  4. Editor behavior can disagree with gowdk check, build, routes, and generated output.
  5. Large workspaces can be scanned more broadly than necessary.

Proposed direction

Route LSP workspace component indexing through the same configured discovery service used by CLI/compiler flows.

The shared discovery path should account for:

  • project root;
  • Source.Include / Source.Exclude;
  • configured modules, when relevant;
  • default exclude patterns;
  • generated output exclusions;
  • open-document overlays.

Acceptance criteria

  • LSP component definitions use configured include/exclude patterns instead of a separate raw WalkDir implementation.
  • Excluded components do not appear in completion/definition results.
  • Module-selected workspaces do not leak components from unrelated modules.
  • Open unsaved component documents are still indexed correctly.
  • Cache invalidation remains deterministic and does not require scanning generated outputs.
  • Tests compare LSP component lookup against CLI/compiler discovery for include/exclude/module cases.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions