swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
743 stars 51 forks source link

Enable syntactic functionality from SourceKit-LSP while the extension is loading the package #753

Closed ahoppen closed 5 months ago

ahoppen commented 5 months ago

Not sure what would be involved here but it looks like the Swift extension only launches SourceKit-LSP after it has loaded the package (eg. resolved package dependencies). When opening SourceKit-LSP, this step takes >10s. During this time, no functionality from SourceKit-LSP is available, for example there is no document outline during this time.

I’m not sure if there’s a hard requirement to only launch sourcekit-lsp after the package has been loaded by the extension but I think it would be worth investigating if we can launch SourceKit-LSP straight away.

adam-fowler commented 5 months ago

Yeah I should be able to move this to an earlier point, at least before the resolve.

adam-fowler commented 5 months ago

I had a look at this and the LanguageClient.start() is called before any projects are loaded. And I've verified the sourcekit-lsp executable is running once that returns.

Stick a breakpoint here to verify https://github.com/swift-server/vscode-swift/blob/dfba3243e6cb97faa45037d11478e2714d4d5e17/src/sourcekit-lsp/LanguageClientManager.ts#L507-L511

ahoppen commented 5 months ago

Oh, sorry, taking this back. Looks like initialization just takes a while in sourcekit-lsp. And I guess it’s doing similar things as resolve packages (or might even be competing for the lock to the .build directory) they probably finish at around the same time, which mislead me.