From e190e1a4342c29e7a4d864f3128d996ab42f560b Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Fri, 11 Aug 2023 17:07:26 +0800 Subject: [PATCH] nvim-0.9.0 compliance for gtags_cscope.vim --- autoload/gutentags/gtags_cscope.vim | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/autoload/gutentags/gtags_cscope.vim b/autoload/gutentags/gtags_cscope.vim index 6a72243..8f51a58 100644 --- a/autoload/gutentags/gtags_cscope.vim +++ b/autoload/gutentags/gtags_cscope.vim @@ -1,8 +1,14 @@ " gtags_cscope module for Gutentags +let s:cscope_native = 1 + if !has('cscope') - throw "Can't enable the gtags-cscope module for Gutentags, " - \"this Vim has no support for cscope files." + if !has('nvim-0.9.0') + throw "Can't enable the gtags-cscope module for Gutentags, " + \"this Vim has no support for cscope files." + else + let s:cscope_native = 0 + endif endif " Global Options {{{ @@ -36,12 +42,14 @@ let s:added_db_files = {} function! s:add_db(db_file) abort if filereadable(a:db_file) - call gutentags#trace( - \"Adding cscope DB file: " . a:db_file) - set nocscopeverbose - execute 'cs add ' . fnameescape(a:db_file) - set cscopeverbose - let s:added_db_files[a:db_file] = 1 + call gutentags#trace( + \"Adding cscope DB file: " . a:db_file) + if s:cscope_native + set nocscopeverbose + execute 'cs add ' . fnameescape(a:db_file) + set cscopeverbose + endif + let s:added_db_files[a:db_file] = 1 else call gutentags#trace( \"Not adding cscope DB file because it doesn't " . @@ -62,7 +70,9 @@ function! gutentags#gtags_cscope#init(project_root) abort let b:gutentags_files['gtags_cscope'] = l:db_file - execute 'set cscopeprg=' . fnameescape(g:gutentags_gtags_cscope_executable) + if s:cscope_native + execute 'set cscopeprg=' . fnameescape(g:gutentags_gtags_cscope_executable) + endif " The combination of gtags-cscope, vim's cscope and global files is " a bit flaky. Environment variables are safer than vim passing