wojciech-kulik / ios-dev-starter-nvim

Bootstrap for iOS development in Neovim + LazyVim
MIT License
79 stars 2 forks source link

LSP diagnostics not updating in open buffers #1

Closed andrelouw closed 9 months ago

andrelouw commented 9 months ago

First off, thank you for putting this starter kit together!! Amazing work 🙏

I have been testing out iOS development using Neovim and ran into a small annoyance with my lsp config, specifically Sourcekit-LSP. When I change a signature in one file, I would expect open buffers to react to that change, i.e, showing error for missing parameters for example. But it seems that changes are only detected when editing the affected buffer again, or by running LspRestart. Even when building, using :XcodebuildBuild, it still doesn't update diagnostics on open buffers.

I thought it was my config at first, but after cloning your config I experienced the same. I then assumed it was a caveat with Sourcekit-LSP, however, running the project in VSCode and the Swift extension, that uses Sourcekit-LSP, changes are detected as expected.

Can you confirm that this is the case when using this starter pack, or is there something I am missing? Any feedback here would be amazing, cause it is driving me nuts 🙈

The Xcode project I used for testing was the template SwiftUI project you get when creating a new project, and my Neovim config was this repo.

wojciech-kulik commented 9 months ago

Hi!

I tested it on my side and I can confirm the same behavior. I'm not sure why it does work in Visual Studio Code. Maybe they track changes in files and explicitly ask LSP to refresh diagnostics?

As a workaround, you could create auto command, listen to InsertLeave and TextChanged and restart LSP then :LspRestart if it's too annoying to you. Or restart LSP manually:

keymap.set("n", "<leader>rl", "<cmd>LspRestart<CR>")

Btw. in Xcode it doesn't always work as well :D

andrelouw commented 9 months ago

Ah wow, thanks for the SUPER quick response!

I will def try the your suggestion. Just for curiosity, how do you go about this in your daily workflow? Do you just build and trace the errors from there?

Also:

Btw. in Xcode it doesn't always work as well :D

I've noticed 😅

Thanks again!

wojciech-kulik commented 9 months ago

You're welcome! Yes, usually after some refactoring I run a build to see if everything works.

Also, with my plugin, all build errors are added to quickfix. So you can run :Telescope quickfix and quickly navigate to all build errors (even from closed buffers, even if LSP doesn't see them yet) 🔥.

You can also use Trouble for quickfix if you want a fancy error panel :)