## versions
vim version: NVIM v0.4.3
node version: v10.19.0
coc.nvim version: 0.0.74
term: alacritty
platform: linux
## Messages
## Output channel: snippets
## Output channel: tsserver
[Info - 3:44:23 PM] Forking TSServer
PATH: /usr/local/sbin:/usr/local/bin:/usr/bin:/home/sqve/.local/bin:/home/sqve/.nvm/versions/node/v10.18.1/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/sqve/.zim/modules/git-extra-commands/bin:/home/sqve/.local/bin:/home/sqve/.nvm/versions/node/v10.19.0/bin:/home/sqve/.zim/modules/git-extra-commands/bin:/home/sqve/.local/bin:/home/sqve/.nvm/versions/node/v10.19.0/bin:/home/sqve/.zim/modules/git-extra-commands/bin
[Info - 3:44:23 PM] Started TSServer
{
"path": "/home/sqve/code/righttp/node_modules/typescript/lib",
"_api": {
"versionString": "3.7.5",
"version": "3.7.5"
}
}
I use the setting "diagnostic.refreshAfterSave": true to only update diagnostics after saving. The problem is that this also excludes running diagnostics when opening a new buffer - ie. when opening a new buffer I need to save straight away for the diagnostics to show up.
Is there a way to refresh diagnostics after save but also when entering a buffer?
Just enable diagnostic.refreshAfterSave in :CocConfig and enter a buffer with diagnostics issues. The issues will only show after saving.
Reproduced.
What you want is:
Am I understanding right?
@fannheyward Correct. I want diagnostics ONLY when entering buffer and after saving. If possible it would be nice to update when the file changes elsewhere, ie. saving in a different editor etc.
Can't fix since all diagnostics are received by notifications.
I've made it refresh for first time when diagnostic received, we can't detect if the buffer is changed outside vim, you have to save it if you want to enable refreshAfterSave or create nested autocmd to save the buffer.
@chemzqm Thank you!
@chemzqm Am I understanding you correctly that I have to, in some way, automatically save the buffer when I open it to get this working? I just tried this code and I do not notice any difference compared to how it was before. The diagnostics of the buffer is only visible after a save.
It works as expected for me, however I can't make it work as expected when you have multiple diagnostic sources.
@chemzqm Strange, it does not for me. I'll try again after a fresh install later today.
@chemzqm No, it does not work for me with diagnostic.refreshAfterSave enabled. When you say multiple diagnostic sources do you mean within coc.nvim or other plugins also?
Most helpful comment
I've made it refresh for first time when diagnostic received, we can't detect if the buffer is changed outside vim, you have to save it if you want to enable
refreshAfterSaveor create nested autocmd to save the buffer.