SolaWing / xcode-build-server

a build server protocol implementation for integrate xcode with sourcekit-lsp
MIT License
283 stars 16 forks source link

[Question] How to show errors from other files? #26

Closed wojciech-kulik closed 7 months ago

wojciech-kulik commented 7 months ago

Hello,

first of all, thank you for this amazing tool. I've been trying for months to run sourcekit-lsp with my projects and finally this tool made it possible effortlessly 🍺 !

I've got one question. Usually, when I break one file it affects other places. For example, if I rename some method,Xcode shows errors in other files. Sourcekit-lsp only shows me errors in currently opened buffers. Is it possible to show also errors from unopened files? This information is already in build logs, so I guess it is just a matter of passing it to vim.diagnostic.

Any help would be very appreciated. Thank you!

PS. Side question: what is buildServer.json does it come from sourcekit-lsp, or is it standard for BuildServerProtocol, or does it come from your tool? Can I find somewhere documentation for this file?

SolaWing commented 7 months ago

diag is generated by sourcekit and currently no way to pass diag from buildServer to lsp.

since you use vim, if you have build log file(for xcode, can be export from log view), you can use :cfile <log path> or :lfile <log path> to read it into quickfix list.

if you use xcode to build, xcode has nice diag navigation, and xcode have a action for Open With External Editor, so just give it a short key, you can quickly open the file from xcode to your editor.

for buildServer specification, see https://build-server-protocol.github.io/docs/specification/. sourcekit-lsp only implements part client capacities of it. you can also see sourcekit-lsp first pr and relavent discussion at here: https://github.com/apple/sourcekit-lsp/pull/152. In fact, xcode-build-server's initial server implementation came from it's test cases

wojciech-kulik commented 7 months ago

Hypothetically, would it be possible to run a build, find errors related to files that are not loaded, and pass them to diagnostics?

I mean abstracting from your tool. I'm not super fluent with nvim, so I would like to confirm that my thinking is correct :). If it's correct, then it shouldn't be super difficult to implement it on my own.

I'm not sure if this is similar to what you mean by loading logs using :cfile (how this command understands xcode build logs)?

Possibly it could result in some duplications after opening this file, but it would be the next step to remove custom diagnostics after the buffer is opened.

SolaWing commented 7 months ago

vim can call external script to build, and readout, extract the error list. but for pass them to merge into diagnostics, I think this might not work. it's not the LSP standard, you should check if your LSP client support additional source. for nvim, you can check help diagnostic to see if you can merge your diag list.

But for the goal that you want to view all diag, you just need a UI to display these file list. In vim, quickfix is the builtin standard way to handle file list, there are many ways to generate it, eg lsp diag, linter plugin, grep, make, file, strings. and there also has plugins like fzf, telescope to quick choose in it. so I can only give suggestion for this, though this will cause you have two file list: one from lsp diag, one from external build, and never merged. you can use help quickfix to see the more details.

wojciech-kulik commented 7 months ago

Great, thank you for the explanation and help! 🍺

wojciech-kulik commented 7 months ago

I managed to make it work by using make command and setting efm. I described the solution here: https://wojciechkulik.pl/ios/how-to-develop-ios-and-macos-apps-in-other-ides-like-neovim-or-vs-code