最新の十分なバージョンのVimがある場合(どちらを使用するかわからないが、を実行するvim --version場合はを参照する必要があります+timers)、非同期タイマーを設定してファイルが変更されたかどうかを確認し、別cfile errors.txtのバージョンを実行してクイックフィックスをリロードすることができますウィンドウの内容。概念実証を次に示します(構文が強調されたバージョンについては、こちらをご覧ください)。
" The filename used for the cfile
let s:cfile_filename = ''
" The last mtime of the filename
let s:cfile_mtime = -1
" Define a command that can be called like:
"
" Cfile errors.txt
"
command! -nargs=1 -complete=file Cfile call s:Cfile(<f-args>)
function! s:Cfile(filename)
let s:cfile_filename = a:filename
" Update every 200ms
let timer = timer_start(200, function('s:UpdateCfile'), {'repeat': -1})
" First "update" to actually load the qf window immediately
call s:UpdateCfile(timer)
endfunction
function! s:UpdateCfile(timer_id)
" Stop the timer if the file is deleted
if s:cfile_filename == '' || !filereadable(s:cfile_filename)
call timer_stop(a:timer_id)
let s:cfile_filename = ''
let s:cfile_mtime = -1
return
endif
" Get file mtime
let mtime = system('stat -c %Y '.shellescape(s:cfile_filename))
" Load the file in the quickfix window if the mtime is newer than the last
" recorded one
if mtime > s:cfile_mtime
exe 'cfile '.s:cfile_filename
let s:cfile_mtime = mtime
endif
endfunction
を.vimrc、またはの別のファイルに配置すると、「実際の」コマンドと同じように使用できるコマンドを~/.vim/plugins/取得できますが、この:Cfileコマンドは200ミリ秒ごとに変更に対してファイルを監視します。ファイルが削除されると、自動更新が停止します。
残念ながら、私はあなたが世話をしなければならないエッジケースがあるだろうと確信しているので、出発点としてこれを使用することをお勧めします、それを理解しようとし:helpますt)を知り、特定のニーズに合った何かを構築します。