Coc.nvim: Run diagnostics when entering buffer

Created on 12 Feb 2020  路  10Comments  路  Source: neoclide/coc.nvim

Result from CocInfo

## 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"
  }
}

Describe the bug

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?

Reproduce the bug

Just enable diagnostic.refreshAfterSave in :CocConfig and enter a buffer with diagnostics issues. The issues will only show after saving.

bug low priority

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 refreshAfterSave or create nested autocmd to save the buffer.

All 10 comments

Reproduced.

What you want is:

  1. diagnostic on enter: YES
  2. diagnostic on doc change: NO
  3. diagnostic on save: YES

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chemzqm picture chemzqm  路  3Comments

rkulla picture rkulla  路  3Comments

skylite21 picture skylite21  路  3Comments

lanox picture lanox  路  3Comments

cvlmtg picture cvlmtg  路  3Comments