swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.32k stars 278 forks source link

Navigation in generated .swiftinterface files #1155

Open akaralar opened 7 months ago

akaralar commented 7 months ago

Is there a way to make the LSP work with .swiftinterface files? For instance when I go to definition of a SwiftUI symbol in my project, say Text, I am directed to a generated SwiftUI.swiftinterface file located in a predefined path which can be seen by running

xcrun --toolchain swift sourcekit-lsp --help

Later in this SwiftUI.swiftinterface file, if I try to go to definition of a symbol in another Swift module, say String, it doesn't navigate there and my editor (Neovim) falls back to finding occurrences in the current file. Also I don't see the LSP attached and LSP says it's running in "single file mode" when I'm in this .swiftinterface file.

If I go back to my project files and try to navigate to String from one of the project files, it navigates me to a Swift.String.swiftinterface file in that same folder for generated interfaces. So I'm guessing there should be a way to send an LSP request for generating an interface even when the originating file is in that generated interfaces folder but I'm not sure how or whether LSP can be configured to do so.

ahoppen commented 7 months ago

Tracked in Apple’s issue tracker as rdar://125663597

akaralar commented 7 months ago

Just a small update, I managed to get LSP to attach when browsing the .swiftinterface file, but it attaches in "single file mode". Whether "single file mode" is something supported by sourcekit-lsp itself is not clear to me, it might as well be a feature of the editor. LSP does not attach when "single file mode" is disabled, my editor seems to think a .swiftinterface file is not part of a project.

Attaching LSP in single file mode does not make a difference in practice, LSP navigation still does not work.