Auto reload file and in neovim and auto reload nerbtree

Viewed 1373

I'm using neovim for coding C++. I have some trouble when coding with it.

I often use file to read and write data. When I run C++ file by command g++ -o data data.cpp && ./data, output file don't reload in neovim.

I try use

set autoread 
au CursorHold * checktime

but it doesn't work.

I don't want to type :e to reload everytime I run code

Additionally, I want to know how to set auto reload nerbtreee when I create new file or folder on Explorer.

Environment:

nvim: 0.4.3
Ubuntu 18.04 LTS
1 Answers

I solved it.

Thanks for spacetime-continuum on Reddit

This is how I configure for this problem:

    " trigger `autoread` when files changes on disk
      set autoread
      autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
    " notification after file change
      autocmd FileChangedShellPost *
        \ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
Related