Skip to content

Instantly share code, notes, and snippets.

@ludovicchabant
Created October 26, 2019 07:21
Show Gist options
  • Save ludovicchabant/b3e0477d38d7817fac64d08944f03a35 to your computer and use it in GitHub Desktop.
Save ludovicchabant/b3e0477d38d7817fac64d08944f03a35 to your computer and use it in GitHub Desktop.
Shut gutentags up when exiting
diff --git a/autoload/gutentags.vim b/autoload/gutentags.vim
--- a/autoload/gutentags.vim
+++ b/autoload/gutentags.vim
@@ -349,6 +349,11 @@ function! gutentags#setup_gutentags() ab
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 {{{
diff --git a/autoload/gutentags/ctags.vim b/autoload/gutentags/ctags.vim
--- a/autoload/gutentags/ctags.vim
+++ b/autoload/gutentags/ctags.vim
@@ -185,7 +185,7 @@ endfunction
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
diff --git a/plugin/gutentags.vim b/plugin/gutentags.vim
--- a/plugin/gutentags.vim
+++ b/plugin/gutentags.vim
@@ -87,6 +87,8 @@ else
let g:gutentags_script_ext = '.sh'
endif
+let g:__gutentags_vim_is_leaving = 0
+
" }}}
" Gutentags Setup {{{
@@ -95,6 +97,7 @@ augroup gutentags_detect
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
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment