The sourcekit-lsp documentation at sourcekit-lsp/Documentation/Enable Experimental Background Indexing.md at main · swiftlang/sourcekit-lsp · GitHub
says:
Background indexing in SourceKit-LSP is enabled by default in Swift 6.1 toolchains and above.
With background indexing disabled, SourceKit-LSP does not update its global index in the background or build Swift modules in the background. Thus, a lot of cross-module or global functionality is limited if the project hasn't been built recently. For example, consider two modules:
LibandExec, whereExecdepends onLib: Without background indexing, if a function is added toLib, completion/jump to definition/etc inExecwould not be able to see that function until after a build. Background indexing solves that issue.
The documentation mentions example modules Lib and Exec. But IMHO the same should apply to different source files within one module. For example, if I have main.swift and helpers.swift files in my swiftPM project, then I open my project folder with VS Code, declare a new let fooConst = 42 in helpers.swift, then start typing foo in main.swift, then I don't see fooConst in code suggestions, until I rebuild the project or close it and reopen in VS Code.
Can this be fixed somehow? Should my code editor (e.g. VS Code or similar) issue a special reindex request to sourcekit-lsp? @ahoppen