I've been working on a BSP to connect sourcekit-lsp and Bazel, and I ran into something involving headers that I wanted to check with you folks what I'm supposed to do.
I've had no issue getting sourcekit-lsp to process and index Swift targets and .m files, but all my header files are "raw":
The way I'm approaching this is that I have build/sources return all header/implementations for Obj-C with the appropriate tags, and then returning the compilation options for the implementation while returning nil for the headers.
This causes the implementation / swift files to correctly point to header file, but the header file itself has no indexing as you can see in the picture. According to the docs sourcekit-lsp should be automatically trying to figure out how to index the header by finding a associated "main file", but I wonder what I've messed up to cause this to not work.
I've been working on a BSP to connect sourcekit-lsp and Bazel
Very cool :)!
According to the docs sourcekit-lsp should be automatically trying to figure out how to index the header by finding a associated "main file"
That should be the case, see eg. ClangLanguageService.buildSettings. Is it possible that we haven't finished indexing the files that include the header?
You can also have a look at (or include here) the extended logging, which should hopefully give us a better idea about what's going on.
Thanks Ben! I can see with the extended logging that it's failing to find the main file. I think it's probably the compiler arguments I return for the .m file then, as looking at Xcode I can see that what sourcekit-lsp is trying to build is slightly different from Xcode (there are some missing index flags from my side among other things). I'll try to add these each of these individually then and see which ones do the trick, will return here once I find out :)
Passing -x objective-c at the beginning and -index-store-path {path} -working-directory {root} did the trick Interestingly the color scheme for .m and .h files are different because Cursor is assuming the header is a C++ file, but that's probably something on my side so I'll ignore that for now. Thanks for the help Ben!
Very cool to see you using the BSP integration for Bazel.
Interesting that -x objective-c is needed. Do you also need to set -x objective-c when building the project? If not, you shouldn’t need to pass it to SourceKit-LSP either. If you are willing to share extended logging without -x objective-c, I would be interested to see it to figure out what’s going on here.