nwolverson / purescript-language-server

MIT License
183 stars 41 forks source link

Suggestion: Extend diagnostics on type to buffer switches #187

Open i-am-the-slime opened 1 year ago

i-am-the-slime commented 1 year ago

I've been happily using the diagnostics on type feature. One inconsistency I find is when I fix all issues in one file and open/switch to another I still have to hit save or type something random to get up to date compiler results for that file.

My first instinct would be to hook into the textDocument_didOpen event.

nwolverson commented 1 year ago

There was something around that already for opened buffers, or was in the past, see the "Build Opened Files" option - not sure if that's currently respected or not, but in theory it should do this already. At the time of starting writing this comment I was under the belief that we can't do arbitrary document focus actions, because there is no corresponding events for alraedy open documents.

However

After reading a comment on the LSP repo I realise that there was at some point added pull-based diagnostics; that didn't seem useful before because the "rebuild" based model didn't lend itself to it, but this could actually be the hook we need:

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentDiagnosticParams

(Depending when it's triggered, it might be better or supplementally useful for on-type diagnostics in general)