From f2e91b1398c512a13bac83c2f34b07b4813b8fd9 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 13 Feb 2020 11:14:25 -0600 Subject: [PATCH] Add vim script --- apps/neovim/.gitignore | 1 + apps/neovim/scripts/pipeline.vim | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 apps/neovim/scripts/pipeline.vim diff --git a/apps/neovim/.gitignore b/apps/neovim/.gitignore index c3702eb..df6ea30 100644 --- a/apps/neovim/.gitignore +++ b/apps/neovim/.gitignore @@ -1,4 +1,5 @@ /* +!/scripts/ !/ftplugin/ !/.gitignore !/init.vim diff --git a/apps/neovim/scripts/pipeline.vim b/apps/neovim/scripts/pipeline.vim new file mode 100644 index 0000000..c6af3cd --- /dev/null +++ b/apps/neovim/scripts/pipeline.vim @@ -0,0 +1,20 @@ +edit $PIPELINE_IN +split $PIPELINE_TRANSFORM +split $PIPELINE_OUT + +let s:refresh_output = {j, d, e -> execute('checktime')} +let s:refresh_output_job = {'spec': ['inotifywait', '-m', '-e', 'close_write,delete', $PIPELINE_OUT], 'opts': {'detach': 1, 'on_stdout': s:refresh_output}} +let s:refresh_output_job_id = jobstart(s:refresh_output_job['spec'], s:refresh_output_job['opts']) + +function s:RunPipeline() + execute "!".g:pipeline_transform +endfunction + +let s:refresh_output_job_id = jobstart(s:refresh_output_job['spec'], s:refresh_output_job['opts']) + +set updatetime=250 +" only autosave the input buffer +autocmd CursorHold,CursorHoldI silent write +autocmd FileWritePost silent call s:RunPipeline() +autocmd VimLeavePre call jobstop(s:refresh_output_job_id) +autocmd VimLeavePre call jobstop(s:run_pipeline_job_id)