2016-11-22 03:36:31 -05:00
|
|
|
let s:plugin_dir = expand('<sfile>:p:h:h:h').'/'
|
|
|
|
let s:log_file = s:plugin_dir.'gitgutter.log'
|
|
|
|
let s:channel_log = s:plugin_dir.'channel.log'
|
|
|
|
let s:new_log_session = 1
|
|
|
|
|
|
|
|
|
|
|
|
function! gitgutter#debug#debug()
|
|
|
|
" Open a scratch buffer
|
|
|
|
vsplit __GitGutter_Debug__
|
|
|
|
normal! ggdG
|
|
|
|
setlocal buftype=nofile
|
|
|
|
setlocal bufhidden=delete
|
|
|
|
setlocal noswapfile
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:vim_version()
|
|
|
|
call s:separator()
|
2016-11-22 03:36:31 -05:00
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:git_version()
|
|
|
|
call s:separator()
|
2016-11-22 03:36:31 -05:00
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:grep_version()
|
|
|
|
call s:separator()
|
2016-11-22 03:36:31 -05:00
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:option('updatetime')
|
2016-11-22 03:36:31 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
function! s:separator()
|
|
|
|
call s:output('')
|
2016-11-22 03:36:31 -05:00
|
|
|
endfunction
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
function! s:vim_version()
|
2016-11-22 03:36:31 -05:00
|
|
|
redir => version_info
|
|
|
|
silent execute 'version'
|
|
|
|
redir END
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:output(split(version_info, '\n')[0:2])
|
2016-11-22 03:36:31 -05:00
|
|
|
endfunction
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
function! s:git_version()
|
2016-11-22 03:36:31 -05:00
|
|
|
let v = system(g:gitgutter_git_executable.' --version')
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:output( substitute(v, '\n$', '', '') )
|
2016-11-22 03:36:31 -05:00
|
|
|
endfunction
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
function! s:grep_version()
|
2020-12-04 16:15:32 -05:00
|
|
|
let v = system(g:gitgutter_grep.' --version')
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:output( substitute(v, '\n$', '', '') )
|
2016-11-22 03:36:31 -05:00
|
|
|
|
2020-12-04 16:15:32 -05:00
|
|
|
let v = system(g:gitgutter_grep.' --help')
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:output( substitute(v, '\%x00', '', 'g') )
|
2016-11-22 03:36:31 -05:00
|
|
|
endfunction
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
function! s:option(name)
|
2016-11-22 03:36:31 -05:00
|
|
|
if exists('+' . a:name)
|
|
|
|
let v = eval('&' . a:name)
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:output(a:name . '=' . v)
|
2016-11-22 03:36:31 -05:00
|
|
|
" redir => output
|
|
|
|
" silent execute "verbose set " . a:name . "?"
|
|
|
|
" redir END
|
2018-03-31 10:56:26 -04:00
|
|
|
" call s:output(a:name . '=' . output)
|
2016-11-22 03:36:31 -05:00
|
|
|
else
|
2018-03-31 10:56:26 -04:00
|
|
|
call s:output(a:name . ' [n/a]')
|
2016-11-22 03:36:31 -05:00
|
|
|
end
|
|
|
|
endfunction
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
function! s:output(text)
|
2016-11-22 03:36:31 -05:00
|
|
|
call append(line('$'), a:text)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" assumes optional args are calling function's optional args
|
|
|
|
function! gitgutter#debug#log(message, ...) abort
|
|
|
|
if g:gitgutter_log
|
|
|
|
if s:new_log_session && gitgutter#async#available()
|
|
|
|
if exists('*ch_logfile')
|
|
|
|
call ch_logfile(s:channel_log, 'w')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
execute 'redir >> '.s:log_file
|
|
|
|
if s:new_log_session
|
|
|
|
let s:start = reltime()
|
|
|
|
silent echo "\n==== start log session ===="
|
|
|
|
endif
|
|
|
|
|
|
|
|
let elapsed = reltimestr(reltime(s:start)).' '
|
|
|
|
silent echo ''
|
|
|
|
" callers excluding this function
|
|
|
|
silent echo elapsed.expand('<sfile>')[:-22].':'
|
|
|
|
silent echo elapsed.s:format_for_log(a:message)
|
|
|
|
if a:0 && !empty(a:1)
|
|
|
|
for msg in a:000
|
|
|
|
silent echo elapsed.s:format_for_log(msg)
|
|
|
|
endfor
|
|
|
|
endif
|
|
|
|
redir END
|
|
|
|
|
|
|
|
let s:new_log_session = 0
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:format_for_log(data) abort
|
|
|
|
if type(a:data) == 1
|
|
|
|
return join(split(a:data,'\n'),"\n")
|
|
|
|
elseif type(a:data) == 3
|
|
|
|
return '['.join(a:data,"\n").']'
|
|
|
|
else
|
|
|
|
return a:data
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|