mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 09:00:06 +08:00
feat(gtags): add more debug info
This commit is contained in:
parent
d6fad97fe7
commit
3d4c29cf5b
@ -186,6 +186,7 @@ function! s:apply(config, type) abort
|
|||||||
unlet value
|
unlet value
|
||||||
endfor
|
endfor
|
||||||
if g:spacevim_debug_level !=# 1
|
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)
|
call SpaceVim#logger#setLevel(g:spacevim_debug_level)
|
||||||
endif
|
endif
|
||||||
let layers = get(a:config, 'layers', [])
|
let layers = get(a:config, 'layers', [])
|
||||||
|
35
bundle/gtags.vim/autoload/gtags.vim
vendored
35
bundle/gtags.vim/autoload/gtags.vim
vendored
@ -1,6 +1,7 @@
|
|||||||
scriptencoding utf-8
|
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')
|
if !executable('gtags')
|
||||||
call s:LOGGER.warn('gtags is not executable, you need to install gnu global!')
|
call s:LOGGER.warn('gtags is not executable, you need to install gnu global!')
|
||||||
@ -12,6 +13,7 @@ if exists('g:loaded_gtags')
|
|||||||
endif
|
endif
|
||||||
let s:JOB = SpaceVim#api#import('job')
|
let s:JOB = SpaceVim#api#import('job')
|
||||||
let s:FILE = SpaceVim#api#import('file')
|
let s:FILE = SpaceVim#api#import('file')
|
||||||
|
let s:NOTI = SpaceVim#api#import('notify')
|
||||||
|
|
||||||
let g:loaded_gtags = 1
|
let g:loaded_gtags = 1
|
||||||
let s:version = split(matchstr(split(system('gtags --version'), '\n')[0], '[0-9]\+\.[0-9]\+'), '\.')
|
let s:version = split(matchstr(split(system('gtags --version'), '\n')[0], '[0-9]\+\.[0-9]\+'), '\.')
|
||||||
@ -124,9 +126,9 @@ endif
|
|||||||
" Display error message.
|
" Display error message.
|
||||||
"
|
"
|
||||||
function! s:Error(msg) abort
|
function! s:Error(msg) abort
|
||||||
echohl WarningMsg |
|
" use notify to display error message
|
||||||
\ echomsg 'Error: ' . a:msg |
|
"
|
||||||
\ echohl None
|
call s:NOTI.notify(a:msg, 'WarningMsg')
|
||||||
endfunction
|
endfunction
|
||||||
"
|
"
|
||||||
" Extract pattern or option string.
|
" Extract pattern or option string.
|
||||||
@ -223,7 +225,13 @@ function! s:ExecGlobal(cmd) abort
|
|||||||
let l:restore_gtagsdbpath = 1
|
let l:restore_gtagsdbpath = 1
|
||||||
endif
|
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)
|
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
|
" restore $GTAGSROOT and $GTAGSDBPATH to make it possible to switch
|
||||||
" between multiple projects or parent/child projects
|
" between multiple projects or parent/child projects
|
||||||
@ -276,7 +284,7 @@ function! s:ExecLoad(option, long_option, pattern) abort
|
|||||||
elseif v:shell_error == 3
|
elseif v:shell_error == 3
|
||||||
call s:Error('GTAGS not found.')
|
call s:Error('GTAGS not found.')
|
||||||
else
|
else
|
||||||
call s:Error('global command failed. command line: ' . l:cmd)
|
call s:Error('global command failed.')
|
||||||
endif
|
endif
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -353,7 +361,7 @@ endfunction
|
|||||||
" RunGlobal()
|
" RunGlobal()
|
||||||
"
|
"
|
||||||
function! gtags#global(line) abort
|
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')
|
let l:pattern = s:Extract(a:line, 'pattern')
|
||||||
|
|
||||||
if l:pattern ==# '%'
|
if l:pattern ==# '%'
|
||||||
@ -459,8 +467,17 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! gtags#update(single_update) abort
|
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)
|
let dir = s:FILE.unify_path(g:tags_cache_dir)
|
||||||
\ . s:FILE.path_to_fname(SpaceVim#plugins#projectmanager#current_root())
|
\ . 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']
|
let cmd = ['gtags']
|
||||||
if !empty(g:gtags_gtagslabel)
|
if !empty(g:gtags_gtagslabel)
|
||||||
let cmd += ['--gtagslabel=' . g:gtags_gtagslabel]
|
let cmd += ['--gtagslabel=' . g:gtags_gtagslabel]
|
||||||
@ -470,11 +487,9 @@ function! gtags#update(single_update) abort
|
|||||||
else
|
else
|
||||||
let cmd += ['--skip-unreadable']
|
let cmd += ['--skip-unreadable']
|
||||||
endif
|
endif
|
||||||
if !isdirectory(dir)
|
|
||||||
call mkdir(dir, 'p')
|
|
||||||
endif
|
|
||||||
let cmd += ['-O', dir]
|
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
|
endfunction
|
||||||
|
|
||||||
function! s:on_update_exit(id, data, event) abort
|
function! s:on_update_exit(id, data, event) abort
|
||||||
|
30
bundle/gtags.vim/autoload/gtags/logger.vim
vendored
30
bundle/gtags.vim/autoload/gtags/logger.vim
vendored
@ -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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
3
bundle/gtags.vim/doc/gtags.txt
vendored
3
bundle/gtags.vim/doc/gtags.txt
vendored
@ -27,9 +27,6 @@ Defaults to 2.
|
|||||||
|
|
||||||
NOTE: when there is only one entry. the quickfix list will not be opened.
|
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*
|
COMMANDS *gtags-commands*
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user