DanielGavin / ols

Language server for Odin
MIT License
439 stars 67 forks source link

Refresh ols on file changes (not only on save) #371

Open thetarnav opened 5 months ago

thetarnav commented 5 months ago

As far as I know, ols currently only "refreshes" (runs odin check, re-collects symbols, etc.) when you save a file. This means that any outside changes to the files are ignored, (e.g. git or scripts generating odin code) and one must do a small change manually, erase it, and save to see the changes. Some editors won't save you if the file is not different in any way, so I imagine that a trick of adding a space, removing it, and saving might not even work there. With re-collecting symbols the problem is worse, because you have to manually update a file that got changed, or restart ols server for it to pick up symbols from the changed file. When meta programming in odin relies on codegen, this is probably worth improving. I'm working with vscode, maybe other editors don't have this issue? But js/ts lsp is able to detect file changes somehow, or just does some polling because I didn't have such issue there. (maybe besides node_modules being overly cached) Is there a way ols could recheck files changed from outside the editor?

DanielGavin commented 5 months ago

It should through this: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeWatchedFiles

But as general rule it should be the client that sends to the server what has changed. So I assume it depends on the client if they support it.

Kaikacy commented 4 months ago

I use neovim and have same problem. it's annoying that you have to save file before seeing diagnostics. I don't think it will be hard to fix or enhance

DanielGavin commented 4 months ago

That will be hard to fix. Considering the diagnostics come from odin check, which requires an actual file. This issue is more about file changes outside the actual file you are changing.