changeset 254:52be4cf89810

Don't complain when the job gets killed when Vim exits. This happens on Neovim, where the jobs seem to get killed before Vim exits, and so Gutentags has enough time to print a warning.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 26 Oct 2019 00:40:18 -0700
parents ec292bfbd633
children 13ab8af33bc1
files autoload/gutentags.vim autoload/gutentags/cscope.vim autoload/gutentags/ctags.vim autoload/gutentags/gtags_cscope.vim plugin/gutentags.vim
diffstat 5 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/autoload/gutentags.vim	Sat Oct 26 01:48:21 2019 -0700
+++ b/autoload/gutentags.vim	Sat Oct 26 00:40:18 2019 -0700
@@ -349,6 +349,11 @@
     endfor
 endfunction
 
+" Set a variable on exit so that we don't complain when a job gets killed.
+function! gutentags#on_vim_leave_pre() abort
+    let g:__gutentags_vim_is_leaving = 1
+endfunction
+
 " }}}
 
 "  Job Management {{{
--- a/autoload/gutentags/cscope.vim	Sat Oct 26 01:48:21 2019 -0700
+++ b/autoload/gutentags/cscope.vim	Sat Oct 26 00:40:18 2019 -0700
@@ -82,7 +82,7 @@
         else
             silent! execute 'cs reset'
         endif
-    else
+    elseif !g:__gutentags_vim_is_leaving
         call gutentags#warning(
                     \"cscope job failed, returned: ".
                     \string(a:exit_val))
--- a/autoload/gutentags/ctags.vim	Sat Oct 26 01:48:21 2019 -0700
+++ b/autoload/gutentags/ctags.vim	Sat Oct 26 00:40:18 2019 -0700
@@ -217,7 +217,7 @@
 function! gutentags#ctags#on_job_exit(job, exit_val) abort
     call gutentags#remove_job_by_data('ctags', a:job)
 
-    if a:exit_val != 0
+    if a:exit_val != 0 && !g:__gutentags_vim_is_leaving
         call gutentags#warning("ctags job failed, returned: ".
                     \string(a:exit_val))
     endif
--- a/autoload/gutentags/gtags_cscope.vim	Sat Oct 26 01:48:21 2019 -0700
+++ b/autoload/gutentags/gtags_cscope.vim	Sat Oct 26 00:40:18 2019 -0700
@@ -112,7 +112,7 @@
         call s:add_db(l:dbfile_path)
     endif
 
-    if a:exit_val != 0
+    if a:exit_val != 0 && !g:__gutentags_vim_is_leaving
         call gutentags#warning(
                     \"gtags-cscope job failed, returned: ".
                     \string(a:exit_val))
--- a/plugin/gutentags.vim	Sat Oct 26 01:48:21 2019 -0700
+++ b/plugin/gutentags.vim	Sat Oct 26 00:40:18 2019 -0700
@@ -87,6 +87,8 @@
     let g:gutentags_script_ext = '.sh'
 endif
 
+let g:__gutentags_vim_is_leaving = 0
+
 " }}}
 
 " Gutentags Setup {{{
@@ -95,6 +97,7 @@
     autocmd!
     autocmd BufNewFile,BufReadPost *  call gutentags#setup_gutentags()
     autocmd VimEnter               *  if expand('<amatch>')==''|call gutentags#setup_gutentags()|endif
+    autocmd VimLeavePre            *  call gutentags#on_vim_leave_pre()
 augroup end
 
 " }}}