diff --git a/autoload/SpaceVim/custom.vim b/autoload/SpaceVim/custom.vim index 4795faf6d..6159142e0 100644 --- a/autoload/SpaceVim/custom.vim +++ b/autoload/SpaceVim/custom.vim @@ -186,6 +186,7 @@ function! s:apply(config, type) abort unlet value endfor if g:spacevim_debug_level !=# 1 + call SpaceVim#logger#debug('change SpaceVim logger level to:' . g:spacevim_debug_level) call SpaceVim#logger#setLevel(g:spacevim_debug_level) endif let layers = get(a:config, 'layers', []) diff --git a/bundle/gtags.vim/autoload/gtags.vim b/bundle/gtags.vim/autoload/gtags.vim index 7ad81cc53..959b255b1 100644 --- a/bundle/gtags.vim/autoload/gtags.vim +++ b/bundle/gtags.vim/autoload/gtags.vim @@ -1,6 +1,7 @@ scriptencoding utf-8 -let s:LOGGER =SpaceVim#logger#derive('gtags') +let s:LOGGER = SpaceVim#logger#derive('gtags') +call s:LOGGER.start_debug() if !executable('gtags') call s:LOGGER.warn('gtags is not executable, you need to install gnu global!') @@ -12,6 +13,7 @@ if exists('g:loaded_gtags') endif let s:JOB = SpaceVim#api#import('job') let s:FILE = SpaceVim#api#import('file') +let s:NOTI = SpaceVim#api#import('notify') let g:loaded_gtags = 1 let s:version = split(matchstr(split(system('gtags --version'), '\n')[0], '[0-9]\+\.[0-9]\+'), '\.') @@ -124,9 +126,9 @@ endif " Display error message. " function! s:Error(msg) abort - echohl WarningMsg | - \ echomsg 'Error: ' . a:msg | - \ echohl None + " use notify to display error message + " + call s:NOTI.notify(a:msg, 'WarningMsg') endfunction " " Extract pattern or option string. @@ -223,7 +225,13 @@ function! s:ExecGlobal(cmd) abort let l:restore_gtagsdbpath = 1 endif + call s:LOGGER.debug('$GTAGSROOT is: ' . $GTAGSROOT) + call s:LOGGER.debug('$GTAGSDBPATH is: ' . $GTAGSDBPATH) + call s:LOGGER.debug('cmd is: ' . a:cmd) let l:result = system(a:cmd) + if v:shell_error !=# 0 + call s:LOGGER.debug('failed to run, v:shell_error is ' . v:shell_error) + endif " restore $GTAGSROOT and $GTAGSDBPATH to make it possible to switch " between multiple projects or parent/child projects @@ -276,7 +284,7 @@ function! s:ExecLoad(option, long_option, pattern) abort elseif v:shell_error == 3 call s:Error('GTAGS not found.') else - call s:Error('global command failed. command line: ' . l:cmd) + call s:Error('global command failed.') endif return endif @@ -353,7 +361,7 @@ endfunction " RunGlobal() " function! gtags#global(line) abort - call gtags#logger#log('info', a:line) + call s:LOGGER.debug('gtags global command: Gtags ' . a:line) let l:pattern = s:Extract(a:line, 'pattern') if l:pattern ==# '%' @@ -459,8 +467,17 @@ endfunction function! gtags#update(single_update) abort + call s:LOGGER.debug('start to update gtags database') let dir = s:FILE.unify_path(g:tags_cache_dir) \ . s:FILE.path_to_fname(SpaceVim#plugins#projectmanager#current_root()) + call s:LOGGER.debug(' dir:' . dir) + call s:LOGGER.debug(' single:' . a:single_update) + if !isdirectory(dir) + if !mkdir(dir, 'p') + call s:LOGGER.debug('failed to create dir:' . dir) + return + endif + endif let cmd = ['gtags'] if !empty(g:gtags_gtagslabel) let cmd += ['--gtagslabel=' . g:gtags_gtagslabel] @@ -470,11 +487,9 @@ function! gtags#update(single_update) abort else let cmd += ['--skip-unreadable'] endif - if !isdirectory(dir) - call mkdir(dir, 'p') - endif let cmd += ['-O', dir] - call s:JOB.start(cmd, {'on_exit' : funcref('s:on_update_exit')}) + call s:LOGGER.debug(' gtags cmd:' . string(cmd)) + call s:LOGGER.debug(' gtags job id:' . s:JOB.start(cmd, {'on_exit' : funcref('s:on_update_exit')})) endfunction function! s:on_update_exit(id, data, event) abort diff --git a/bundle/gtags.vim/autoload/gtags/logger.vim b/bundle/gtags.vim/autoload/gtags/logger.vim deleted file mode 100644 index 54641581f..000000000 --- a/bundle/gtags.vim/autoload/gtags/logger.vim +++ /dev/null @@ -1,30 +0,0 @@ -scriptencoding utf-8 - -let s:LOG = SpaceVim#api#import('logger') - -call s:LOG.set_name('Gtags') - -"" -" set the path to gtags log file. -let g:gtags_log_file = get(g:, 'gtags_log_file', '') - -if !empty(g:gtags_log_file) - call s:LOG.set_file(g:gtags_log_file) -endif - -function! gtags#logger#log(level, msg) abort - if a:level ==# 'info' - call s:LOG.info(a:msg) - elseif a:level ==# 'warn' - call s:LOG.warn(a:msg) - elseif a:level ==# 'error' - call s:LOG.error(a:msg) - endif -endfunction - -function! gtags#logger#view(...) - echo s:LOG.view(get(a:000, 0, 'info')) -endfunction - - - diff --git a/bundle/gtags.vim/doc/gtags.txt b/bundle/gtags.vim/doc/gtags.txt index 9437b699b..c1ff760bd 100644 --- a/bundle/gtags.vim/doc/gtags.txt +++ b/bundle/gtags.vim/doc/gtags.txt @@ -27,9 +27,6 @@ Defaults to 2. NOTE: when there is only one entry. the quickfix list will not be opened. - *g:gtags_log_file* -set the path to gtags log file. - ============================================================================== COMMANDS *gtags-commands*