Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optionally disable realtime running of diagnotics #566

Closed
rcr opened this issue Nov 17, 2019 · 7 comments
Closed

Optionally disable realtime running of diagnotics #566

rcr opened this issue Nov 17, 2019 · 7 comments

Comments

@rcr
Copy link

rcr commented Nov 17, 2019

Running diagnostics in realtime doesn't make sense. For example, running the compiler while typing code generates compilation errors for missing semicolons before I'm finished typing the line out. I'd like to control when diagnostics are run, on BufWrite, or after a timeout period.

@mattn
Copy link
Collaborator

mattn commented Nov 21, 2019

Diagnostics are notification messages from server. Unfortunately, Language Server Specification does not have spec for customize to disable diagnotic.

See TextDocumentClientCapabilities in https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/

@mattn mattn closed this as completed Nov 21, 2019
@rcr
Copy link
Author

rcr commented Nov 21, 2019

How does the server running the diagnostics know that the content has changed if it's just in nvim's internal buffer and hasn't been saved to disk? Clearly there has to be some mechanism alerting the server of changes in realtime...

@prabirshrestha
Copy link
Owner

you can use g:lsp_diagnostics_enabled to hide the signs error if that is what you are looking for.

@rcr
Copy link
Author

rcr commented Nov 22, 2019

Not quite. I want the diagnostics, I just don't want them to be recalculated on every keystroke, that doesn't make sense. You wouldn't run your compiler after every keystroke. I'm wondering if there's an option to have diagnostics refreshed, for example, on BufWrite.

@mattn
Copy link
Collaborator

mattn commented Nov 22, 2019

To not send the text until saving mean to not support hover, completion, or most of features of language server.

@rcr
Copy link
Author

rcr commented Nov 22, 2019

Ahh, hadn't considered that, good point. However I've been looking at the protocol and it looks like after any given "textDocument/didChange" event you could feasibly ignore the "diagnostics" json struct returned from the server unless it was expected? I might try to hack something out myself for this, it really does seem to me like the behavior the average user might expect.

@acomagu
Copy link

acomagu commented Jan 30, 2020

@rcr Setting g:lsp_diagnostics_enabled = 0 stops the updating diagnostics message, because vim-lsp seems to check the variable every time on receiving publishDiagnostics event(autoload/lsp.vim#L703).

I guess g:lsp_diagnostics_enabled should be 1 on startup(when lsp#enable() is called) so this trick is hacky a little, but works.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants