neoclide / coc-git

Git integration of coc.nvim
419 stars 40 forks source link

vim-coc gets out of sync when I make changes outside of Vim #126

Closed oconnor663 closed 4 years ago

oconnor663 commented 4 years ago

Here's an example that seems to trigger this:

  1. Edit a line in an open text file and save the file. Vim-coc puts the ~ symbol in the signcolumn.
  2. Run git reset --hard outside of Vim.
  3. Execute :e inside Vim.

Expected: The ~ should go away (eventually). Actual: The ~ remains indefinitely.

Am I wrong about the expected behavior here? Is there a way to make vim-coc poll for changes on the filesystem? What's the best way to manually "refresh" it when it gets into this state?

chemzqm commented 4 years ago

:e should work, please provide vim information.

oconnor663 commented 4 years ago

I'm sorry, I should've done that at the beginning. This is on Manjaro Linux:

NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include

My vimrc is visible here: https://github.com/oconnor663/dotfiles/blob/44d325b3066fa77d395da23ed824b2ca0313aef4/vimrc And my full set of plugins is visible here: https://github.com/oconnor663/dotfiles/blob/44d325b3066fa77d395da23ed824b2ca0313aef4/peru.yaml

The plugins list is:

oconnor663 commented 4 years ago

A simpler repro for me is:

  1. Edit a file in a git repo. Don't save it.
  2. Undo the edit with :e!.

For me the ~ appears in step 1 (correctly) but remains in step 2 (incorrectly).

chemzqm commented 4 years ago

:e doesn't reload buffer on neovim 0.4.3, it's recommended to use neovim 0.5.0. Try add

autocmd CursorHold * CocCommand git.refresh

to your vimrc.

oconnor663 commented 4 years ago

Oh my god, autoread in NeoVim nightly is amazing. I didn't even know this was a thing :)