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

LspDocumentDiagnostics runs before file is fully saved #695

Closed
jhod0 opened this issue Jan 29, 2020 · 2 comments
Closed

LspDocumentDiagnostics runs before file is fully saved #695

jhod0 opened this issue Jan 29, 2020 · 2 comments
Labels

Comments

@jhod0
Copy link

jhod0 commented Jan 29, 2020

To automatically show diagnostics when I save a file, I added the following to my .vimrc:

autocmd BufWritePost * LspDocumentDiagnostics

However, using pyls, if I add something like the following to a file, and then write with :w:

dummy_string = 'Hello there!'

I get the diagnostic message EOL while scanning string literal. When I write again a second later, it gives the correct diagnostics. It seems like lsp is using diagnostics from a partially-updated file?

I may just be using vim-lsp wrong, in which case a suggestion how to do this properly would be appreciated. Thanks!

@stale
Copy link

stale bot commented Oct 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 18, 2020
@stale stale bot closed this as completed Oct 25, 2020
@Daniel-viberg
Copy link

Daniel-viberg commented Mar 9, 2023

My work around for this issue:

function! FormatAndWrite()
LspDocumentFormatSync
:w
endfunction
autocmd BufWritePost * silent! call FormatAndWrite()

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

No branches or pull requests

2 participants