mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 01:09:56 +08:00
feat(tagbar): use default logger system
This commit is contained in:
parent
75800458a2
commit
02fadf00ff
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
!0/
|
!0/
|
||||||
|
.spacevim.log
|
||||||
doc/tags
|
doc/tags
|
||||||
doc/tags-cn
|
doc/tags-cn
|
||||||
.ropeproject/
|
.ropeproject/
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
|
|
||||||
if has('nvim-0.5.0')
|
if has('nvim-0.5.0')
|
||||||
|
""
|
||||||
|
" write message to SpaceVim runtime log with `info` level.
|
||||||
function! SpaceVim#logger#info(msg) abort
|
function! SpaceVim#logger#info(msg) abort
|
||||||
lua require("spacevim.logger").info(
|
lua require("spacevim.logger").info(
|
||||||
\ require("spacevim").eval("a:msg")
|
\ require("spacevim").eval("a:msg")
|
||||||
@ -55,7 +57,26 @@ if has('nvim-0.5.0')
|
|||||||
function! SpaceVim#logger#setOutput(file) abort
|
function! SpaceVim#logger#setOutput(file) abort
|
||||||
lua require("spacevim.logger").setOutput(require("spacevim").eval("a:file"))
|
lua require("spacevim.logger").setOutput(require("spacevim").eval("a:file"))
|
||||||
endfunction
|
endfunction
|
||||||
|
""
|
||||||
|
" Derive a new logger based on SpaceVim's runtime logger. The new logger
|
||||||
|
" provides following functions:
|
||||||
|
" 1. info(msg): like |SpaceVim#logger#info|, but include the derive name.
|
||||||
|
" 2. warn(msg): like |SpaceVim#logger#warn|
|
||||||
|
" 3. error(msg): like |SpaceVim#logger#error|
|
||||||
|
" 4. debug(msg): write debug message run SpaceVim runtime log
|
||||||
|
" 5. start_debug(): enable debug mode of derived logger.
|
||||||
|
" 6. stop_debug(): stop debug mode of derived logger.
|
||||||
|
"
|
||||||
|
" Example: >
|
||||||
|
" let s:LOGGER = SpaceVim#logger#derive('myplug')
|
||||||
|
"
|
||||||
|
" call s:LOGGER.info('hello world')
|
||||||
|
" <
|
||||||
|
"
|
||||||
|
" The this info message will be write to SpaceVim's runtime log:
|
||||||
|
" >
|
||||||
|
" [ myplug ] [00:02:54:051] [ Info ] hello world
|
||||||
|
" <
|
||||||
function! SpaceVim#logger#derive(name) abort
|
function! SpaceVim#logger#derive(name) abort
|
||||||
return luaeval('require("spacevim.logger").derive(require("spacevim").eval("a:name"))')
|
return luaeval('require("spacevim.logger").derive(require("spacevim").eval("a:name"))')
|
||||||
endfunction
|
endfunction
|
||||||
@ -176,6 +197,8 @@ else
|
|||||||
|
|
||||||
let s:derive = {}
|
let s:derive = {}
|
||||||
let s:derive.origin_name = s:LOGGER.get_name()
|
let s:derive.origin_name = s:LOGGER.get_name()
|
||||||
|
" let s:derive._debug_mode = v:false
|
||||||
|
let s:derive._debug_mode = 0
|
||||||
|
|
||||||
function! s:derive.info(msg) abort
|
function! s:derive.info(msg) abort
|
||||||
call s:LOGGER.set_name(self.derive_name)
|
call s:LOGGER.set_name(self.derive_name)
|
||||||
@ -196,9 +219,19 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:derive.debug(msg) abort
|
function! s:derive.debug(msg) abort
|
||||||
|
if self._debug_mode
|
||||||
call s:LOGGER.set_name(self.derive_name)
|
call s:LOGGER.set_name(self.derive_name)
|
||||||
call s:LOGGER.debug(a:msg)
|
call s:LOGGER.debug(a:msg)
|
||||||
call s:LOGGER.set_name(self.origin_name)
|
call s:LOGGER.set_name(self.origin_name)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:derive.start_debug() abort
|
||||||
|
let self._debug_mode = 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:derive.stop_debug() abort
|
||||||
|
let self._debug_mode = 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#logger#derive(name) abort
|
function! SpaceVim#logger#derive(name) abort
|
||||||
|
205
bundle/tagbar/autoload/tagbar.vim
vendored
205
bundle/tagbar/autoload/tagbar.vim
vendored
@ -230,7 +230,7 @@ endfunction
|
|||||||
|
|
||||||
" s:InitTypes() {{{2
|
" s:InitTypes() {{{2
|
||||||
function! s:InitTypes() abort
|
function! s:InitTypes() abort
|
||||||
call tagbar#debug#log('Initializing types')
|
call tagbar#log#debug('Initializing types')
|
||||||
|
|
||||||
let supported_types = s:GetSupportedFiletypes()
|
let supported_types = s:GetSupportedFiletypes()
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ function! s:InitTypes() abort
|
|||||||
let dart_ctags = s:CheckFTCtags('dart_ctags', 'dart')
|
let dart_ctags = s:CheckFTCtags('dart_ctags', 'dart')
|
||||||
if dart_ctags !=# ''
|
if dart_ctags !=# ''
|
||||||
let supported_types['dart'] = 1
|
let supported_types['dart'] = 1
|
||||||
call tagbar#debug#log('Detected dart_ctags, overriding typedef')
|
call tagbar#log#debug('Detected dart_ctags, overriding typedef')
|
||||||
let type_dart = tagbar#prototypes#typeinfo#new()
|
let type_dart = tagbar#prototypes#typeinfo#new()
|
||||||
let type_dart.ctagstype = 'dart'
|
let type_dart.ctagstype = 'dart'
|
||||||
let type_dart.kinds = [
|
let type_dart.kinds = [
|
||||||
@ -299,7 +299,7 @@ function! s:InitTypes() abort
|
|||||||
" Use jsctags/doctorjs if available
|
" Use jsctags/doctorjs if available
|
||||||
let jsctags = s:CheckFTCtags('jsctags', 'javascript')
|
let jsctags = s:CheckFTCtags('jsctags', 'javascript')
|
||||||
if jsctags !=# ''
|
if jsctags !=# ''
|
||||||
call tagbar#debug#log('Detected jsctags, overriding typedef')
|
call tagbar#log#debug('Detected jsctags, overriding typedef')
|
||||||
let type_javascript = tagbar#prototypes#typeinfo#new()
|
let type_javascript = tagbar#prototypes#typeinfo#new()
|
||||||
let type_javascript.ctagstype = 'javascript'
|
let type_javascript.ctagstype = 'javascript'
|
||||||
let type_javascript.kinds = [
|
let type_javascript.kinds = [
|
||||||
@ -324,7 +324,7 @@ function! s:InitTypes() abort
|
|||||||
" Use gotags if available
|
" Use gotags if available
|
||||||
let gotags = s:CheckFTCtags('gotags', 'go')
|
let gotags = s:CheckFTCtags('gotags', 'go')
|
||||||
if gotags !=# ''
|
if gotags !=# ''
|
||||||
call tagbar#debug#log('Detected gotags, overriding typedef')
|
call tagbar#log#debug('Detected gotags, overriding typedef')
|
||||||
let type_go = tagbar#prototypes#typeinfo#new()
|
let type_go = tagbar#prototypes#typeinfo#new()
|
||||||
let type_go.ctagstype = 'go'
|
let type_go.ctagstype = 'go'
|
||||||
let type_go.kinds = [
|
let type_go.kinds = [
|
||||||
@ -395,7 +395,7 @@ function! s:LoadUserTypeDefs(...) abort
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
for [key, value] in items(transformed)
|
for [key, value] in items(transformed)
|
||||||
call tagbar#debug#log("Initializing user type '" . key . "'")
|
call tagbar#log#debug("Initializing user type '" . key . "'")
|
||||||
if !has_key(s:known_types, key) || get(value, 'replace', 0)
|
if !has_key(s:known_types, key) || get(value, 'replace', 0)
|
||||||
let s:known_types[key] = tagbar#prototypes#typeinfo#new(value)
|
let s:known_types[key] = tagbar#prototypes#typeinfo#new(value)
|
||||||
else
|
else
|
||||||
@ -443,11 +443,11 @@ endfunction
|
|||||||
" Properly restore Tagbar after a session got loaded
|
" Properly restore Tagbar after a session got loaded
|
||||||
function! s:RestoreSession() abort
|
function! s:RestoreSession() abort
|
||||||
if s:init_done
|
if s:init_done
|
||||||
call tagbar#debug#log('Tagbar already initialized; not restoring session')
|
call tagbar#log#debug('Tagbar already initialized; not restoring session')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('Restoring session')
|
call tagbar#log#debug('Restoring session')
|
||||||
|
|
||||||
let curfile = fnamemodify(bufname('%'), ':p')
|
let curfile = fnamemodify(bufname('%'), ':p')
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ endfunction
|
|||||||
|
|
||||||
" s:MapKeys() {{{2
|
" s:MapKeys() {{{2
|
||||||
function! s:MapKeys() abort
|
function! s:MapKeys() abort
|
||||||
call tagbar#debug#log('Mapping keys')
|
call tagbar#log#debug('Mapping keys')
|
||||||
|
|
||||||
nnoremap <script> <silent> <buffer> <2-LeftMouse>
|
nnoremap <script> <silent> <buffer> <2-LeftMouse>
|
||||||
\ :call <SID>JumpToTag(0)<CR>
|
\ :call <SID>JumpToTag(0)<CR>
|
||||||
@ -544,7 +544,7 @@ endfunction
|
|||||||
|
|
||||||
" s:CreateAutocommands() {{{2
|
" s:CreateAutocommands() {{{2
|
||||||
function! s:CreateAutocommands() abort
|
function! s:CreateAutocommands() abort
|
||||||
call tagbar#debug#log('Creating autocommands')
|
call tagbar#log#debug('Creating autocommands')
|
||||||
|
|
||||||
augroup TagbarAutoCmds
|
augroup TagbarAutoCmds
|
||||||
autocmd!
|
autocmd!
|
||||||
@ -623,7 +623,7 @@ endfunction
|
|||||||
" Test whether the ctags binary is actually Exuberant Ctags and not BSD ctags
|
" Test whether the ctags binary is actually Exuberant Ctags and not BSD ctags
|
||||||
" (or something else)
|
" (or something else)
|
||||||
function! s:CheckForExCtags(silent) abort
|
function! s:CheckForExCtags(silent) abort
|
||||||
call tagbar#debug#log('Checking for Exuberant Ctags')
|
call tagbar#log#debug('Checking for Exuberant Ctags')
|
||||||
|
|
||||||
if !exists('g:tagbar_ctags_bin')
|
if !exists('g:tagbar_ctags_bin')
|
||||||
let ctagsbins = []
|
let ctagsbins = []
|
||||||
@ -679,8 +679,8 @@ function! s:CheckForExCtags(silent) abort
|
|||||||
|
|
||||||
let ctags_output = s:ExecuteCtags(ctags_cmd)
|
let ctags_output = s:ExecuteCtags(ctags_cmd)
|
||||||
|
|
||||||
call tagbar#debug#log("Command output:\n" . ctags_output)
|
call tagbar#log#debug("Command output:\n" . ctags_output)
|
||||||
call tagbar#debug#log('Exit code: ' . v:shell_error)
|
call tagbar#log#debug('Exit code: ' . v:shell_error)
|
||||||
|
|
||||||
if v:shell_error || ctags_output !~# '\(Exuberant\|Universal\) Ctags'
|
if v:shell_error || ctags_output !~# '\(Exuberant\|Universal\) Ctags'
|
||||||
let l:errmsg = 'Tagbar: Ctags doesn''t seem to be Exuberant Ctags!'
|
let l:errmsg = 'Tagbar: Ctags doesn''t seem to be Exuberant Ctags!'
|
||||||
@ -707,7 +707,7 @@ endfunction
|
|||||||
|
|
||||||
" s:CtagsErrMsg() {{{2
|
" s:CtagsErrMsg() {{{2
|
||||||
function! s:CtagsErrMsg(errmsg, infomsg, silent, ...) abort
|
function! s:CtagsErrMsg(errmsg, infomsg, silent, ...) abort
|
||||||
call tagbar#debug#log(a:errmsg)
|
call tagbar#log#debug(a:errmsg)
|
||||||
let ctags_cmd = a:0 > 0 ? a:1 : ''
|
let ctags_cmd = a:0 > 0 ? a:1 : ''
|
||||||
let ctags_output = a:0 > 1 ? a:2 : ''
|
let ctags_output = a:0 > 1 ? a:2 : ''
|
||||||
|
|
||||||
@ -742,21 +742,21 @@ endfunction
|
|||||||
|
|
||||||
" s:CheckExCtagsVersion() {{{2
|
" s:CheckExCtagsVersion() {{{2
|
||||||
function! s:CheckExCtagsVersion(output) abort
|
function! s:CheckExCtagsVersion(output) abort
|
||||||
call tagbar#debug#log('Checking Exuberant Ctags version')
|
call tagbar#log#debug('Checking Exuberant Ctags version')
|
||||||
|
|
||||||
if a:output =~? 'Universal Ctags'
|
if a:output =~? 'Universal Ctags'
|
||||||
call tagbar#debug#log('Found Universal Ctags, assuming compatibility')
|
call tagbar#log#debug('Found Universal Ctags, assuming compatibility')
|
||||||
let s:ctags_is_uctags = 1
|
let s:ctags_is_uctags = 1
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:output =~? 'Exuberant Ctags compatiable PHP enhancement'
|
if a:output =~? 'Exuberant Ctags compatiable PHP enhancement'
|
||||||
call tagbar#debug#log('Found phpctags, assuming compatibility')
|
call tagbar#log#debug('Found phpctags, assuming compatibility')
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:output =~? 'Exuberant Ctags Development'
|
if a:output =~? 'Exuberant Ctags Development'
|
||||||
call tagbar#debug#log('Found development version, assuming compatibility')
|
call tagbar#log#debug('Found development version, assuming compatibility')
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ function! s:CheckExCtagsVersion(output) abort
|
|||||||
let major = matchlist[1]
|
let major = matchlist[1]
|
||||||
let minor = matchlist[2]
|
let minor = matchlist[2]
|
||||||
|
|
||||||
call tagbar#debug#log("Ctags version: major='" . major . "', minor='" . minor . "'")
|
call tagbar#log#debug("Ctags version: major='" . major . "', minor='" . minor . "'")
|
||||||
|
|
||||||
return major >= 6 || (major == 5 && minor >= 5)
|
return major >= 6 || (major == 5 && minor >= 5)
|
||||||
endfunction
|
endfunction
|
||||||
@ -789,7 +789,7 @@ endfunction
|
|||||||
|
|
||||||
" s:GetSupportedFiletypes() {{{2
|
" s:GetSupportedFiletypes() {{{2
|
||||||
function! s:GetSupportedFiletypes() abort
|
function! s:GetSupportedFiletypes() abort
|
||||||
call tagbar#debug#log('Getting filetypes supported by Exuberant Ctags')
|
call tagbar#log#debug('Getting filetypes supported by Exuberant Ctags')
|
||||||
|
|
||||||
let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--list-languages')
|
let ctags_cmd = s:EscapeCtagsCmd(g:tagbar_ctags_bin, '--list-languages')
|
||||||
if ctags_cmd ==# ''
|
if ctags_cmd ==# ''
|
||||||
@ -845,7 +845,7 @@ endfunction
|
|||||||
" s:known_files.rm() {{{2
|
" s:known_files.rm() {{{2
|
||||||
function! s:known_files.rm(fname) abort dict
|
function! s:known_files.rm(fname) abort dict
|
||||||
if s:known_files.has(a:fname)
|
if s:known_files.has(a:fname)
|
||||||
call tagbar#debug#log('Removing fileinfo for [' . a:fname . ']')
|
call tagbar#log#debug('Removing fileinfo for [' . a:fname . ']')
|
||||||
call remove(self._files, a:fname)
|
call remove(self._files, a:fname)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -853,7 +853,7 @@ endfunction
|
|||||||
" Window management {{{1
|
" Window management {{{1
|
||||||
" s:ToggleWindow() {{{2
|
" s:ToggleWindow() {{{2
|
||||||
function! s:ToggleWindow(flags) abort
|
function! s:ToggleWindow(flags) abort
|
||||||
call tagbar#debug#log('ToggleWindow called')
|
call tagbar#log#debug('ToggleWindow called')
|
||||||
|
|
||||||
let tagbarwinnr = bufwinnr(s:TagbarBufName())
|
let tagbarwinnr = bufwinnr(s:TagbarBufName())
|
||||||
if tagbarwinnr != -1
|
if tagbarwinnr != -1
|
||||||
@ -863,12 +863,12 @@ function! s:ToggleWindow(flags) abort
|
|||||||
|
|
||||||
call s:OpenWindow(a:flags)
|
call s:OpenWindow(a:flags)
|
||||||
|
|
||||||
call tagbar#debug#log('ToggleWindow finished')
|
call tagbar#log#debug('ToggleWindow finished')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" s:OpenWindow() {{{2
|
" s:OpenWindow() {{{2
|
||||||
function! s:OpenWindow(flags) abort
|
function! s:OpenWindow(flags) abort
|
||||||
call tagbar#debug#log("OpenWindow called with flags: '" . a:flags . "'")
|
call tagbar#log#debug("OpenWindow called with flags: '" . a:flags . "'")
|
||||||
|
|
||||||
let autofocus = a:flags =~# 'f'
|
let autofocus = a:flags =~# 'f'
|
||||||
let jump = a:flags =~# 'j'
|
let jump = a:flags =~# 'j'
|
||||||
@ -885,7 +885,7 @@ function! s:OpenWindow(flags) abort
|
|||||||
call s:goto_win(tagbarwinnr)
|
call s:goto_win(tagbarwinnr)
|
||||||
call s:HighlightTag(g:tagbar_autoshowtag != 2, 1, 1, curline)
|
call s:HighlightTag(g:tagbar_autoshowtag != 2, 1, 1, curline)
|
||||||
endif
|
endif
|
||||||
call tagbar#debug#log('OpenWindow finished, Tagbar already open')
|
call tagbar#log#debug('OpenWindow finished, Tagbar already open')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -974,12 +974,12 @@ function! s:OpenWindow(flags) abort
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('OpenWindow finished')
|
call tagbar#log#debug('OpenWindow finished')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" s:InitWindow() {{{2
|
" s:InitWindow() {{{2
|
||||||
function! s:InitWindow(autoclose) abort
|
function! s:InitWindow(autoclose) abort
|
||||||
call tagbar#debug#log('InitWindow called with autoclose: ' . a:autoclose)
|
call tagbar#log#debug('InitWindow called with autoclose: ' . a:autoclose)
|
||||||
|
|
||||||
" Buffer-local options
|
" Buffer-local options
|
||||||
|
|
||||||
@ -1069,12 +1069,12 @@ function! s:InitWindow(autoclose) abort
|
|||||||
let s:expand_bufnr = bufnr('%')
|
let s:expand_bufnr = bufnr('%')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('InitWindow finished')
|
call tagbar#log#debug('InitWindow finished')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" s:CloseWindow() {{{2
|
" s:CloseWindow() {{{2
|
||||||
function! s:CloseWindow() abort
|
function! s:CloseWindow() abort
|
||||||
call tagbar#debug#log('CloseWindow called')
|
call tagbar#log#debug('CloseWindow called')
|
||||||
|
|
||||||
let tagbarwinnr = bufwinnr(s:TagbarBufName())
|
let tagbarwinnr = bufwinnr(s:TagbarBufName())
|
||||||
if tagbarwinnr == -1
|
if tagbarwinnr == -1
|
||||||
@ -1127,7 +1127,7 @@ function! s:CloseWindow() abort
|
|||||||
call tagbar#StopAutoUpdate()
|
call tagbar#StopAutoUpdate()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('CloseWindow finished')
|
call tagbar#log#debug('CloseWindow finished')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" s:ShrinkIfExpanded() {{{2
|
" s:ShrinkIfExpanded() {{{2
|
||||||
@ -1207,21 +1207,21 @@ endfunction
|
|||||||
" s:ProcessFile() {{{2
|
" s:ProcessFile() {{{2
|
||||||
" Execute ctags and put the information into a 'FileInfo' object
|
" Execute ctags and put the information into a 'FileInfo' object
|
||||||
function! s:ProcessFile(fname, ftype) abort
|
function! s:ProcessFile(fname, ftype) abort
|
||||||
call tagbar#debug#log('ProcessFile called [' . a:fname . ']')
|
call tagbar#log#debug('ProcessFile called [' . a:fname . ']')
|
||||||
|
|
||||||
if !s:IsValidFile(a:fname, a:ftype)
|
if !s:IsValidFile(a:fname, a:ftype)
|
||||||
call tagbar#debug#log('Not a valid file, returning')
|
call tagbar#log#debug('Not a valid file, returning')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:bufnum = bufnr(a:fname)
|
let l:bufnum = bufnr(a:fname)
|
||||||
|
|
||||||
if !bufloaded(l:bufnum)
|
if !bufloaded(l:bufnum)
|
||||||
call tagbar#debug#log('[ProcessFile] Buffer is not loaded exiting...')
|
call tagbar#log#debug('[ProcessFile] Buffer is not loaded exiting...')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if !bufexists(l:bufnum)
|
if !bufexists(l:bufnum)
|
||||||
call tagbar#debug#log('[ProcessFile] Buffer does not exist exiting...')
|
call tagbar#log#debug('[ProcessFile] Buffer does not exist exiting...')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1246,12 +1246,12 @@ function! s:ProcessFile(fname, ftype) abort
|
|||||||
let fileinfo = tagbar#prototypes#fileinfo#new(a:fname, a:ftype, typeinfo)
|
let fileinfo = tagbar#prototypes#fileinfo#new(a:fname, a:ftype, typeinfo)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('typeinfo for file to process: ' . string(typeinfo))
|
call tagbar#log#debug('typeinfo for file to process: ' . string(typeinfo))
|
||||||
|
|
||||||
if g:tagbar_file_size_limit > 0
|
if g:tagbar_file_size_limit > 0
|
||||||
\ && fileinfo.fsize > g:tagbar_file_size_limit
|
\ && fileinfo.fsize > g:tagbar_file_size_limit
|
||||||
\ && !exists('b:tagbar_force_update')
|
\ && !exists('b:tagbar_force_update')
|
||||||
call tagbar#debug#log('File size exceeds defined limit')
|
call tagbar#log#debug('File size exceeds defined limit')
|
||||||
let fileinfo.fsize_exceeded = 1
|
let fileinfo.fsize_exceeded = 1
|
||||||
call s:known_files.put(fileinfo)
|
call s:known_files.put(fileinfo)
|
||||||
return
|
return
|
||||||
@ -1265,12 +1265,12 @@ function! s:ProcessFile(fname, ftype) abort
|
|||||||
let tempfile .= '.' . ext
|
let tempfile .= '.' . ext
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('Caching file into: ' . tempfile)
|
call tagbar#log#debug('Caching file into: ' . tempfile)
|
||||||
let templines = getbufline(fileinfo.bufnr, 1, '$')
|
let templines = getbufline(fileinfo.bufnr, 1, '$')
|
||||||
let res = writefile(templines, tempfile)
|
let res = writefile(templines, tempfile)
|
||||||
|
|
||||||
if res != 0
|
if res != 0
|
||||||
call tagbar#debug#log('Could not create copy '.tempfile)
|
call tagbar#log#debug('Could not create copy '.tempfile)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let fileinfo.mtime = getftime(tempfile)
|
let fileinfo.mtime = getftime(tempfile)
|
||||||
@ -1278,23 +1278,23 @@ function! s:ProcessFile(fname, ftype) abort
|
|||||||
|
|
||||||
let ctags_output = s:ExecuteCtagsOnFile(tempfile, a:fname, typeinfo)
|
let ctags_output = s:ExecuteCtagsOnFile(tempfile, a:fname, typeinfo)
|
||||||
|
|
||||||
if !tagbar#debug#enabled()
|
if !tagbar#log#enabled()
|
||||||
call delete(tempfile)
|
call delete(tempfile)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call tagbar#debug#log('File caching disabled')
|
call tagbar#log#debug('File caching disabled')
|
||||||
let fileinfo.fsize_exceeded = 0
|
let fileinfo.fsize_exceeded = 0
|
||||||
let ctags_output = s:ExecuteCtagsOnFile(a:fname, a:fname, typeinfo)
|
let ctags_output = s:ExecuteCtagsOnFile(a:fname, a:fname, typeinfo)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ctags_output == -1
|
if ctags_output == -1
|
||||||
call tagbar#debug#log('Ctags error when processing file')
|
call tagbar#log#debug('Ctags error when processing file')
|
||||||
" Put an empty entry into known_files so the error message is only
|
" Put an empty entry into known_files so the error message is only
|
||||||
" shown once
|
" shown once
|
||||||
call s:known_files.put({}, a:fname)
|
call s:known_files.put({}, a:fname)
|
||||||
return
|
return
|
||||||
elseif ctags_output ==# ''
|
elseif ctags_output ==# ''
|
||||||
call tagbar#debug#log('Ctags output empty')
|
call tagbar#log#debug('Ctags output empty')
|
||||||
" No need to go through the tag processing if there are no tags, and
|
" No need to go through the tag processing if there are no tags, and
|
||||||
" preserving the old fold state isn't necessary either
|
" preserving the old fold state isn't necessary either
|
||||||
call s:known_files.put(tagbar#prototypes#fileinfo#new(a:fname, a:ftype,
|
call s:known_files.put(tagbar#prototypes#fileinfo#new(a:fname, a:ftype,
|
||||||
@ -1302,10 +1302,10 @@ function! s:ProcessFile(fname, ftype) abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('Filetype tag kinds: ' . string(keys(typeinfo.kinddict)))
|
call tagbar#log#debug('Filetype tag kinds: ' . string(keys(typeinfo.kinddict)))
|
||||||
|
|
||||||
" Parse the ctags output lines
|
" Parse the ctags output lines
|
||||||
call tagbar#debug#log('Parsing ctags output')
|
call tagbar#log#debug('Parsing ctags output')
|
||||||
let rawtaglist = split(ctags_output, '\n\+')
|
let rawtaglist = split(ctags_output, '\n\+')
|
||||||
let seen = {}
|
let seen = {}
|
||||||
for line in rawtaglist
|
for line in rawtaglist
|
||||||
@ -1314,7 +1314,7 @@ function! s:ProcessFile(fname, ftype) abort
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if g:tagbar_ignore_anonymous && line =~# '__anon'
|
if g:tagbar_ignore_anonymous && line =~# '__anon'
|
||||||
call tagbar#debug#log('anonymous tag found - ignoring per tagbar configuration')
|
call tagbar#log#debug('anonymous tag found - ignoring per tagbar configuration')
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1336,7 +1336,7 @@ function! s:ProcessFile(fname, ftype) abort
|
|||||||
let curtags = filter(copy(fileinfo.getTags()),
|
let curtags = filter(copy(fileinfo.getTags()),
|
||||||
\ 'v:val.fields.kind ==# kind.short && ' .
|
\ 'v:val.fields.kind ==# kind.short && ' .
|
||||||
\ '!has_key(v:val, "scope")')
|
\ '!has_key(v:val, "scope")')
|
||||||
call tagbar#debug#log('Processing kind: ' . kind.short .
|
call tagbar#log#debug('Processing kind: ' . kind.short .
|
||||||
\ ', number of tags: ' . len(curtags))
|
\ ', number of tags: ' . len(curtags))
|
||||||
|
|
||||||
if empty(curtags)
|
if empty(curtags)
|
||||||
@ -1364,7 +1364,7 @@ endfunction
|
|||||||
|
|
||||||
" s:ExecuteCtagsOnFile() {{{2
|
" s:ExecuteCtagsOnFile() {{{2
|
||||||
function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
|
function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
|
||||||
call tagbar#debug#log('ExecuteCtagsOnFile called [' . a:fname . ']')
|
call tagbar#log#debug('ExecuteCtagsOnFile called [' . a:fname . ']')
|
||||||
|
|
||||||
if has_key(a:typeinfo, 'ctagsargs') && type(a:typeinfo.ctagsargs) == type('')
|
if has_key(a:typeinfo, 'ctagsargs') && type(a:typeinfo.ctagsargs) == type('')
|
||||||
" if ctagsargs is a string, prepend and append space separators
|
" if ctagsargs is a string, prepend and append space separators
|
||||||
@ -1404,7 +1404,7 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
|
|||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" verbose if debug enabled
|
" verbose if debug enabled
|
||||||
if tagbar#debug#enabled()
|
if tagbar#log#enabled()
|
||||||
let ctags_args += [ '-V' ]
|
let ctags_args += [ '-V' ]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1454,9 +1454,9 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
|
|||||||
let ctags_output = s:ExecuteCtags(ctags_cmd)
|
let ctags_output = s:ExecuteCtags(ctags_cmd)
|
||||||
|
|
||||||
if v:shell_error || ctags_output =~? 'Warning: cannot open \(source\|input\) file'
|
if v:shell_error || ctags_output =~? 'Warning: cannot open \(source\|input\) file'
|
||||||
call tagbar#debug#log('Command output:')
|
call tagbar#log#debug('Command output:')
|
||||||
call tagbar#debug#log(ctags_output)
|
call tagbar#log#debug(ctags_output)
|
||||||
call tagbar#debug#log('Exit code: ' . v:shell_error)
|
call tagbar#log#debug('Exit code: ' . v:shell_error)
|
||||||
" Only display an error message if the Tagbar window is open and we
|
" Only display an error message if the Tagbar window is open and we
|
||||||
" haven't seen the error before.
|
" haven't seen the error before.
|
||||||
if bufwinnr(s:TagbarBufName()) != -1 &&
|
if bufwinnr(s:TagbarBufName()) != -1 &&
|
||||||
@ -1475,8 +1475,7 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
|
|||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('Ctags executed successfully')
|
call tagbar#log#debug('Ctags executed successfully')
|
||||||
call tagbar#debug#log_ctags_output(ctags_output)
|
|
||||||
|
|
||||||
return ctags_output
|
return ctags_output
|
||||||
endfunction
|
endfunction
|
||||||
@ -1605,7 +1604,7 @@ function! s:ProcessTag(name, filename, pattern, fields, is_split, typeinfo, file
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if !has_key(taginfo.fields, 'kind')
|
if !has_key(taginfo.fields, 'kind')
|
||||||
call tagbar#debug#log(
|
call tagbar#log#debug(
|
||||||
\ "Warning: No 'kind' field found for tag " . a:name[0] . '!')
|
\ "Warning: No 'kind' field found for tag " . a:name[0] . '!')
|
||||||
if index(s:warnings.type, a:typeinfo.ftype) == -1
|
if index(s:warnings.type, a:typeinfo.ftype) == -1
|
||||||
call s:warning("No 'kind' field found for tag " . a:name[0] . '!' .
|
call s:warning("No 'kind' field found for tag " . a:name[0] . '!' .
|
||||||
@ -1658,7 +1657,7 @@ function! s:ProcessTag(name, filename, pattern, fields, is_split, typeinfo, file
|
|||||||
call taginfo.initFoldState(s:known_files)
|
call taginfo.initFoldState(s:known_files)
|
||||||
catch /^Vim(\a\+):E716:/ " 'Key not present in Dictionary'
|
catch /^Vim(\a\+):E716:/ " 'Key not present in Dictionary'
|
||||||
" The tag has a 'kind' that doesn't exist in the type definition
|
" The tag has a 'kind' that doesn't exist in the type definition
|
||||||
call tagbar#debug#log('Warning: Unknown tag kind: ' . taginfo.fields.kind)
|
call tagbar#log#debug('Warning: Unknown tag kind: ' . taginfo.fields.kind)
|
||||||
if index(s:warnings.type, a:typeinfo.ftype) == -1
|
if index(s:warnings.type, a:typeinfo.ftype) == -1
|
||||||
call s:warning('Unknown tag kind encountered: ' .
|
call s:warning('Unknown tag kind encountered: ' .
|
||||||
\ '"' . taginfo.fields.kind . '".' .
|
\ '"' . taginfo.fields.kind . '".' .
|
||||||
@ -1908,7 +1907,7 @@ endfunction
|
|||||||
" Display {{{1
|
" Display {{{1
|
||||||
" s:RenderContent() {{{2
|
" s:RenderContent() {{{2
|
||||||
function! s:RenderContent(...) abort
|
function! s:RenderContent(...) abort
|
||||||
call tagbar#debug#log('RenderContent called')
|
call tagbar#log#debug('RenderContent called')
|
||||||
let s:new_window = 0
|
let s:new_window = 0
|
||||||
|
|
||||||
if a:0 == 1
|
if a:0 == 1
|
||||||
@ -1918,7 +1917,7 @@ function! s:RenderContent(...) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if empty(fileinfo)
|
if empty(fileinfo)
|
||||||
call tagbar#debug#log('Empty fileinfo, returning')
|
call tagbar#log#debug('Empty fileinfo, returning')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1942,7 +1941,7 @@ function! s:RenderContent(...) abort
|
|||||||
if !empty(tagbar#state#get_current_file(0)) &&
|
if !empty(tagbar#state#get_current_file(0)) &&
|
||||||
\ fileinfo.fpath ==# tagbar#state#get_current_file(0).fpath
|
\ fileinfo.fpath ==# tagbar#state#get_current_file(0).fpath
|
||||||
" We're redisplaying the same file, so save the view
|
" We're redisplaying the same file, so save the view
|
||||||
call tagbar#debug#log('Redisplaying file [' . fileinfo.fpath . ']')
|
call tagbar#log#debug('Redisplaying file [' . fileinfo.fpath . ']')
|
||||||
let saveline = line('.')
|
let saveline = line('.')
|
||||||
let savecol = col('.')
|
let savecol = col('.')
|
||||||
let topline = line('w0')
|
let topline = line('w0')
|
||||||
@ -1974,7 +1973,7 @@ function! s:RenderContent(...) abort
|
|||||||
" Print tags
|
" Print tags
|
||||||
call s:PrintKinds(typeinfo, fileinfo)
|
call s:PrintKinds(typeinfo, fileinfo)
|
||||||
else
|
else
|
||||||
call tagbar#debug#log('No tags found, skipping printing.')
|
call tagbar#log#debug('No tags found, skipping printing.')
|
||||||
if g:tagbar_compact && s:short_help
|
if g:tagbar_compact && s:short_help
|
||||||
silent 0put ='\" No tags found.'
|
silent 0put ='\" No tags found.'
|
||||||
else
|
else
|
||||||
@ -2024,7 +2023,7 @@ endfunction
|
|||||||
|
|
||||||
" s:PrintKinds() {{{2
|
" s:PrintKinds() {{{2
|
||||||
function! s:PrintKinds(typeinfo, fileinfo) abort
|
function! s:PrintKinds(typeinfo, fileinfo) abort
|
||||||
call tagbar#debug#log('PrintKinds called')
|
call tagbar#log#debug('PrintKinds called')
|
||||||
|
|
||||||
" If the short or long help is being displayed then the line numbers don't
|
" If the short or long help is being displayed then the line numbers don't
|
||||||
" match up with the length of the output list
|
" match up with the length of the output list
|
||||||
@ -2034,7 +2033,7 @@ function! s:PrintKinds(typeinfo, fileinfo) abort
|
|||||||
for kind in a:typeinfo.kinds
|
for kind in a:typeinfo.kinds
|
||||||
let curtags = filter(copy(a:fileinfo.getTags()),
|
let curtags = filter(copy(a:fileinfo.getTags()),
|
||||||
\ 'v:val.fields.kind ==# kind.short')
|
\ 'v:val.fields.kind ==# kind.short')
|
||||||
call tagbar#debug#log('Printing kind: ' . kind.short .
|
call tagbar#log#debug('Printing kind: ' . kind.short .
|
||||||
\ ', number of (top-level) tags: ' . len(curtags))
|
\ ', number of (top-level) tags: ' . len(curtags))
|
||||||
|
|
||||||
if empty(curtags)
|
if empty(curtags)
|
||||||
@ -2328,7 +2327,7 @@ function! s:HighlightTag(openfolds, ...) abort
|
|||||||
else
|
else
|
||||||
let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\?' . identifier . '/'
|
let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\?' . identifier . '/'
|
||||||
endif
|
endif
|
||||||
call tagbar#debug#log("Highlight pattern: '" . pattern . "'")
|
call tagbar#log#debug("Highlight pattern: '" . pattern . "'")
|
||||||
if hlexists('TagbarHighlight') " Safeguard in case syntax highlighting is disabled
|
if hlexists('TagbarHighlight') " Safeguard in case syntax highlighting is disabled
|
||||||
execute 'match TagbarHighlight ' . pattern
|
execute 'match TagbarHighlight ' . pattern
|
||||||
else
|
else
|
||||||
@ -2400,13 +2399,13 @@ function! s:JumpToTag(stay_in_tagbar, ...) abort
|
|||||||
" Jump to the line where the tag is defined. Don't use the search pattern
|
" Jump to the line where the tag is defined. Don't use the search pattern
|
||||||
" since it doesn't take the scope into account and thus can fail if tags
|
" since it doesn't take the scope into account and thus can fail if tags
|
||||||
" with the same name are defined in different scopes (e.g. classes)
|
" with the same name are defined in different scopes (e.g. classes)
|
||||||
call tagbar#debug#log('Jumping to line ' . taginfo.fields.line)
|
call tagbar#log#debug('Jumping to line ' . taginfo.fields.line)
|
||||||
execute taginfo.fields.line
|
execute taginfo.fields.line
|
||||||
|
|
||||||
" If the file has been changed but not saved, the tag may not be on the
|
" If the file has been changed but not saved, the tag may not be on the
|
||||||
" saved line anymore, so search for it in the vicinity of the saved line
|
" saved line anymore, so search for it in the vicinity of the saved line
|
||||||
if taginfo.pattern !=# ''
|
if taginfo.pattern !=# ''
|
||||||
call tagbar#debug#log('Searching for pattern "' . taginfo.pattern . '"')
|
call tagbar#log#debug('Searching for pattern "' . taginfo.pattern . '"')
|
||||||
if match(getline('.'), taginfo.pattern) == -1
|
if match(getline('.'), taginfo.pattern) == -1
|
||||||
let interval = 1
|
let interval = 1
|
||||||
let forward = 1
|
let forward = 1
|
||||||
@ -2839,7 +2838,7 @@ endfunction
|
|||||||
" Helper functions {{{1
|
" Helper functions {{{1
|
||||||
" s:AutoUpdate() {{{2
|
" s:AutoUpdate() {{{2
|
||||||
function! s:AutoUpdate(fname, force, ...) abort
|
function! s:AutoUpdate(fname, force, ...) abort
|
||||||
call tagbar#debug#log('AutoUpdate called [' . a:fname . ']')
|
call tagbar#log#debug('AutoUpdate called [' . a:fname . ']')
|
||||||
|
|
||||||
" Whether we want to skip actually displaying the tags in Tagbar and only
|
" Whether we want to skip actually displaying the tags in Tagbar and only
|
||||||
" update the fileinfo
|
" update the fileinfo
|
||||||
@ -2856,7 +2855,7 @@ function! s:AutoUpdate(fname, force, ...) abort
|
|||||||
" break. MiniBufExplorer does this, for example. Completely disabling
|
" break. MiniBufExplorer does this, for example. Completely disabling
|
||||||
" autocmds at that point is also not ideal since for example
|
" autocmds at that point is also not ideal since for example
|
||||||
" statusline plugins won't be able to update.
|
" statusline plugins won't be able to update.
|
||||||
call tagbar#debug#log('Still opening window, stopping processing')
|
call tagbar#log#debug('Still opening window, stopping processing')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -2866,18 +2865,18 @@ function! s:AutoUpdate(fname, force, ...) abort
|
|||||||
|
|
||||||
" Don't do anything if we're in the tagbar window
|
" Don't do anything if we're in the tagbar window
|
||||||
if ftype ==# 'tagbar'
|
if ftype ==# 'tagbar'
|
||||||
call tagbar#debug#log('In Tagbar window, stopping processing')
|
call tagbar#log#debug('In Tagbar window, stopping processing')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Only consider the main filetype in cases like 'python.django'
|
" Only consider the main filetype in cases like 'python.django'
|
||||||
let sftype = get(split(ftype, '\.'), 0, '')
|
let sftype = get(split(ftype, '\.'), 0, '')
|
||||||
call tagbar#debug#log("Vim filetype: '" . ftype . "', " .
|
call tagbar#log#debug("Vim filetype: '" . ftype . "', " .
|
||||||
\ "sanitized filetype: '" . sftype . "'")
|
\ "sanitized filetype: '" . sftype . "'")
|
||||||
|
|
||||||
" Don't do anything if the file isn't supported
|
" Don't do anything if the file isn't supported
|
||||||
if !s:IsValidFile(a:fname, sftype)
|
if !s:IsValidFile(a:fname, sftype)
|
||||||
call tagbar#debug#log('Not a valid file, stopping processing')
|
call tagbar#log#debug('Not a valid file, stopping processing')
|
||||||
let s:nearby_disabled = 1
|
let s:nearby_disabled = 1
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -2893,14 +2892,14 @@ function! s:AutoUpdate(fname, force, ...) abort
|
|||||||
" if a:force || getbufvar(curfile.bufnr, '&modified') ||
|
" if a:force || getbufvar(curfile.bufnr, '&modified') ||
|
||||||
if a:force || empty(curfile) || curfile.ftype != sftype ||
|
if a:force || empty(curfile) || curfile.ftype != sftype ||
|
||||||
\ (filereadable(a:fname) && getftime(a:fname) > curfile.mtime)
|
\ (filereadable(a:fname) && getftime(a:fname) > curfile.mtime)
|
||||||
call tagbar#debug#log('File data outdated, updating [' . a:fname . ']')
|
call tagbar#log#debug('File data outdated, updating [' . a:fname . ']')
|
||||||
call s:ProcessFile(a:fname, sftype)
|
call s:ProcessFile(a:fname, sftype)
|
||||||
let updated = 1
|
let updated = 1
|
||||||
else
|
else
|
||||||
call tagbar#debug#log('File data seems up to date [' . a:fname . ']')
|
call tagbar#log#debug('File data seems up to date [' . a:fname . ']')
|
||||||
endif
|
endif
|
||||||
elseif !s:known_files.has(a:fname)
|
elseif !s:known_files.has(a:fname)
|
||||||
call tagbar#debug#log('New file, processing [' . a:fname . ']')
|
call tagbar#log#debug('New file, processing [' . a:fname . ']')
|
||||||
call s:ProcessFile(a:fname, sftype)
|
call s:ProcessFile(a:fname, sftype)
|
||||||
let updated = 1
|
let updated = 1
|
||||||
endif
|
endif
|
||||||
@ -2914,7 +2913,7 @@ function! s:AutoUpdate(fname, force, ...) abort
|
|||||||
" If we don't have an entry for the file by now something must have gone
|
" If we don't have an entry for the file by now something must have gone
|
||||||
" wrong, so don't change the tagbar content
|
" wrong, so don't change the tagbar content
|
||||||
if empty(fileinfo)
|
if empty(fileinfo)
|
||||||
call tagbar#debug#log('fileinfo empty after processing [' . a:fname . ']')
|
call tagbar#log#debug('fileinfo empty after processing [' . a:fname . ']')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -2930,14 +2929,14 @@ function! s:AutoUpdate(fname, force, ...) abort
|
|||||||
" Call setCurrent after rendering so RenderContent can check whether the
|
" Call setCurrent after rendering so RenderContent can check whether the
|
||||||
" same file is being redisplayed
|
" same file is being redisplayed
|
||||||
if !empty(fileinfo)
|
if !empty(fileinfo)
|
||||||
call tagbar#debug#log('Setting current file [' . a:fname . ']')
|
call tagbar#log#debug('Setting current file [' . a:fname . ']')
|
||||||
call tagbar#state#set_current_file(fileinfo)
|
call tagbar#state#set_current_file(fileinfo)
|
||||||
let s:nearby_disabled = 0
|
let s:nearby_disabled = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:HighlightTag(0, 1)
|
call s:HighlightTag(0, 1)
|
||||||
call s:SetStatusLine()
|
call s:SetStatusLine()
|
||||||
call tagbar#debug#log('AutoUpdate finished successfully')
|
call tagbar#log#debug('AutoUpdate finished successfully')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" s:CheckMouseClick() {{{2
|
" s:CheckMouseClick() {{{2
|
||||||
@ -2998,12 +2997,12 @@ endfunction
|
|||||||
" is acceptable. But in cases where arguments may need to be escaped
|
" is acceptable. But in cases where arguments may need to be escaped
|
||||||
" differently for each &shell type, then pass a list of arguments.
|
" differently for each &shell type, then pass a list of arguments.
|
||||||
function! s:EscapeCtagsCmd(ctags_bin, args, ...) abort
|
function! s:EscapeCtagsCmd(ctags_bin, args, ...) abort
|
||||||
call tagbar#debug#log('EscapeCtagsCmd called')
|
call tagbar#log#debug('EscapeCtagsCmd called')
|
||||||
call tagbar#debug#log('ctags_bin: ' . a:ctags_bin)
|
call tagbar#log#debug('ctags_bin: ' . a:ctags_bin)
|
||||||
if type(a:args)==type('')
|
if type(a:args)==type('')
|
||||||
call tagbar#debug#log('ctags_args (is a string): ' . a:args)
|
call tagbar#log#debug('ctags_args (is a string): ' . a:args)
|
||||||
elseif type(a:args)==type([])
|
elseif type(a:args)==type([])
|
||||||
call tagbar#debug#log('ctags_args (is a list): ' . string(a:args))
|
call tagbar#log#debug('ctags_args (is a list): ' . string(a:args))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('+shellslash')
|
if exists('+shellslash')
|
||||||
@ -3078,7 +3077,7 @@ function! s:EscapeCtagsCmd(ctags_bin, args, ...) abort
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call tagbar#debug#log('Escaped ctags command: ' . ctags_cmd)
|
call tagbar#log#debug('Escaped ctags command: ' . ctags_cmd)
|
||||||
|
|
||||||
if ctags_cmd ==# ''
|
if ctags_cmd ==# ''
|
||||||
if !s:warnings.encoding
|
if !s:warnings.encoding
|
||||||
@ -3130,7 +3129,7 @@ endfunction
|
|||||||
" Partially based on the discussion at
|
" Partially based on the discussion at
|
||||||
" http://vim.1045645.n5.nabble.com/bad-default-shellxquote-in-Widows-td1208284.html
|
" http://vim.1045645.n5.nabble.com/bad-default-shellxquote-in-Widows-td1208284.html
|
||||||
function! s:ExecuteCtags(ctags_cmd) abort
|
function! s:ExecuteCtags(ctags_cmd) abort
|
||||||
call tagbar#debug#log('Executing ctags command: ' . a:ctags_cmd)
|
call tagbar#log#debug('Executing ctags command: ' . a:ctags_cmd)
|
||||||
|
|
||||||
if &shell =~# 'fish$'
|
if &shell =~# 'fish$'
|
||||||
" Reset shell since fish isn't really compatible
|
" Reset shell since fish isn't really compatible
|
||||||
@ -3156,10 +3155,10 @@ function! s:ExecuteCtags(ctags_cmd) abort
|
|||||||
set shellcmdflag=/s\ /c
|
set shellcmdflag=/s\ /c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if tagbar#debug#enabled()
|
if tagbar#log#enabled()
|
||||||
silent 5verbose let ctags_output = system(a:ctags_cmd)
|
silent 5verbose let ctags_output = system(a:ctags_cmd)
|
||||||
call tagbar#debug#log(v:statusmsg)
|
call tagbar#log#debug(v:statusmsg)
|
||||||
call tagbar#debug#log('Exit code: ' . v:shell_error)
|
call tagbar#log#debug('Exit code: ' . v:shell_error)
|
||||||
redraw!
|
redraw!
|
||||||
else
|
else
|
||||||
let py_version = get(g:, 'tagbar_python', 1)
|
let py_version = get(g:, 'tagbar_python', 1)
|
||||||
@ -3413,31 +3412,31 @@ endfunction
|
|||||||
|
|
||||||
" s:IsValidFile() {{{2
|
" s:IsValidFile() {{{2
|
||||||
function! s:IsValidFile(fname, ftype) abort
|
function! s:IsValidFile(fname, ftype) abort
|
||||||
call tagbar#debug#log('Checking if file is valid [' . a:fname . ']')
|
call tagbar#log#debug('Checking if file is valid [' . a:fname . ']')
|
||||||
|
|
||||||
if a:fname ==# '' || a:ftype ==# ''
|
if a:fname ==# '' || a:ftype ==# ''
|
||||||
call tagbar#debug#log('Empty filename or type')
|
call tagbar#log#debug('Empty filename or type')
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !filereadable(a:fname) && getbufvar(a:fname, 'netrw_tmpfile') ==# ''
|
if !filereadable(a:fname) && getbufvar(a:fname, 'netrw_tmpfile') ==# ''
|
||||||
call tagbar#debug#log('File not readable')
|
call tagbar#log#debug('File not readable')
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if getbufvar(a:fname, 'tagbar_ignore') == 1
|
if getbufvar(a:fname, 'tagbar_ignore') == 1
|
||||||
call tagbar#debug#log('File is marked as ignored')
|
call tagbar#log#debug('File is marked as ignored')
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let winnr = bufwinnr(a:fname)
|
let winnr = bufwinnr(a:fname)
|
||||||
if winnr != -1 && getwinvar(winnr, '&diff')
|
if winnr != -1 && getwinvar(winnr, '&diff')
|
||||||
call tagbar#debug#log('Window is in diff mode')
|
call tagbar#log#debug('Window is in diff mode')
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if &previewwindow
|
if &previewwindow
|
||||||
call tagbar#debug#log('In preview window')
|
call tagbar#log#debug('In preview window')
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -3447,7 +3446,7 @@ function! s:IsValidFile(fname, ftype) abort
|
|||||||
" file, so load it now
|
" file, so load it now
|
||||||
call s:LoadUserTypeDefs(a:ftype)
|
call s:LoadUserTypeDefs(a:ftype)
|
||||||
else
|
else
|
||||||
call tagbar#debug#log('Unsupported filetype: ' . a:ftype)
|
call tagbar#log#debug('Unsupported filetype: ' . a:ftype)
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -3521,13 +3520,13 @@ function! s:HandleOnlyWindow() abort
|
|||||||
let file_open = s:HasOpenFileWindows()
|
let file_open = s:HasOpenFileWindows()
|
||||||
|
|
||||||
if vim_quitting && file_open == 2 && !g:tagbar_autoclose_netrw
|
if vim_quitting && file_open == 2 && !g:tagbar_autoclose_netrw
|
||||||
call tagbar#debug#log('Closing Tagbar due to QuitPre - netrw only remaining window')
|
call tagbar#log#debug('Closing Tagbar due to QuitPre - netrw only remaining window')
|
||||||
call s:CloseWindow()
|
call s:CloseWindow()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if vim_quitting && file_open != 1
|
if vim_quitting && file_open != 1
|
||||||
call tagbar#debug#log('Closing Tagbar window due to QuitPre event')
|
call tagbar#log#debug('Closing Tagbar window due to QuitPre event')
|
||||||
if winnr('$') >= 1
|
if winnr('$') >= 1
|
||||||
call s:goto_win(tagbarwinnr, 1)
|
call s:goto_win(tagbarwinnr, 1)
|
||||||
endif
|
endif
|
||||||
@ -3677,7 +3676,7 @@ function! s:HasOpenFileWindows() abort
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
if netrw
|
if netrw
|
||||||
call tagbar#debug#log('netrw only window remaining')
|
call tagbar#log#debug('netrw only window remaining')
|
||||||
return 2
|
return 2
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@ -3711,7 +3710,7 @@ function! s:goto_win(winnr, ...) abort
|
|||||||
\ : 'wincmd ' . a:winnr
|
\ : 'wincmd ' . a:winnr
|
||||||
let noauto = a:0 > 0 ? a:1 : 0
|
let noauto = a:0 > 0 ? a:1 : 0
|
||||||
|
|
||||||
call tagbar#debug#log('goto_win(): ' . cmd . ', ' . noauto)
|
call tagbar#log#debug('goto_win(): ' . cmd . ', ' . noauto)
|
||||||
|
|
||||||
if noauto
|
if noauto
|
||||||
noautocmd execute cmd
|
noautocmd execute cmd
|
||||||
@ -3878,7 +3877,7 @@ endfunction
|
|||||||
" Automatically open Tagbar if one of the open buffers contains a supported
|
" Automatically open Tagbar if one of the open buffers contains a supported
|
||||||
" file
|
" file
|
||||||
function! tagbar#autoopen(...) abort
|
function! tagbar#autoopen(...) abort
|
||||||
call tagbar#debug#log('tagbar#autoopen called [' . bufname('%') . ']')
|
call tagbar#log#debug('tagbar#autoopen called [' . bufname('%') . ']')
|
||||||
let always = a:0 > 0 ? a:1 : 1
|
let always = a:0 > 0 ? a:1 : 1
|
||||||
|
|
||||||
call s:Init(0)
|
call s:Init(0)
|
||||||
@ -3888,14 +3887,14 @@ function! tagbar#autoopen(...) abort
|
|||||||
let ftype = s:DetectFiletype(bufnr)
|
let ftype = s:DetectFiletype(bufnr)
|
||||||
if s:IsValidFile(bufname(bufnr), ftype)
|
if s:IsValidFile(bufname(bufnr), ftype)
|
||||||
call s:OpenWindow('')
|
call s:OpenWindow('')
|
||||||
call tagbar#debug#log('tagbar#autoopen finished after finding valid ' .
|
call tagbar#log#debug('tagbar#autoopen finished after finding valid ' .
|
||||||
\ 'file [' . bufname(bufnr) . ']')
|
\ 'file [' . bufname(bufnr) . ']')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
call tagbar#debug#log('tagbar#autoopen finished without finding valid file')
|
call tagbar#log#debug('tagbar#autoopen finished without finding valid file')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" tagbar#GetTagNearLine() {{{2
|
" tagbar#GetTagNearLine() {{{2
|
||||||
@ -4053,23 +4052,23 @@ endfunction
|
|||||||
|
|
||||||
" tagbar#printfileinfo() {{{2
|
" tagbar#printfileinfo() {{{2
|
||||||
function! tagbar#printfileinfo() abort
|
function! tagbar#printfileinfo() abort
|
||||||
if !tagbar#debug#enabled()
|
if !tagbar#log#enabled()
|
||||||
echo 'Tagbar debug is disabled - unable to print fileinfo to tagbar log'
|
echo 'Tagbar debug is disabled - unable to print fileinfo to tagbar log'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let fileinfo = tagbar#state#get_current_file(0)
|
let fileinfo = tagbar#state#get_current_file(0)
|
||||||
if empty(fileinfo)
|
if empty(fileinfo)
|
||||||
call tagbar#debug#log('File contains no tag entries')
|
call tagbar#log#debug('File contains no tag entries')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let typeinfo = fileinfo.typeinfo
|
let typeinfo = fileinfo.typeinfo
|
||||||
|
|
||||||
call tagbar#debug#log('Printing fileinfo [' . fileinfo.fpath . ' lines:' . fileinfo.lnum)
|
call tagbar#log#debug('Printing fileinfo [' . fileinfo.fpath . ' lines:' . fileinfo.lnum)
|
||||||
for line in range(1, fileinfo.lnum)
|
for line in range(1, fileinfo.lnum)
|
||||||
if has_key(fileinfo.fline, line)
|
if has_key(fileinfo.fline, line)
|
||||||
let tag = fileinfo.fline[line]
|
let tag = fileinfo.fline[line]
|
||||||
call tagbar#debug#log(' '
|
call tagbar#log#debug(' '
|
||||||
\ . ' line:' . line
|
\ . ' line:' . line
|
||||||
\ . ' kind:' . tag.fields.kind
|
\ . ' kind:' . tag.fields.kind
|
||||||
\ . ' depth:' . tag.depth
|
\ . ' depth:' . tag.depth
|
||||||
@ -4077,7 +4076,7 @@ function! tagbar#printfileinfo() abort
|
|||||||
\ )
|
\ )
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call tagbar#debug#log('All tags printed')
|
call tagbar#log#debug('All tags printed')
|
||||||
|
|
||||||
echo 'Tagbar fileinfo printed to debug logfile'
|
echo 'Tagbar fileinfo printed to debug logfile'
|
||||||
endfunction
|
endfunction
|
||||||
@ -4116,5 +4115,3 @@ function! tagbar#jumpToNearbyTag(direction, ...) abort
|
|||||||
call s:JumpToNearbyTag(a:direction, search_method, flags)
|
call s:JumpToNearbyTag(a:direction, search_method, flags)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Modeline {{{1
|
|
||||||
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
|
|
||||||
|
62
bundle/tagbar/autoload/tagbar/debug.vim
vendored
62
bundle/tagbar/autoload/tagbar/debug.vim
vendored
@ -1,62 +0,0 @@
|
|||||||
function! tagbar#debug#start_debug(...) abort
|
|
||||||
let filename = a:0 > 0 ? a:1 : ''
|
|
||||||
|
|
||||||
if empty(filename)
|
|
||||||
let s:debug_file = 'tagbardebug.log'
|
|
||||||
else
|
|
||||||
let s:debug_file = filename
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Clear log file and start it with version info
|
|
||||||
exe 'redir! > ' . s:debug_file
|
|
||||||
silent version
|
|
||||||
redir END
|
|
||||||
|
|
||||||
" Check whether the log file could be created
|
|
||||||
if !filewritable(s:debug_file)
|
|
||||||
echomsg 'Tagbar: Unable to create log file ' . s:debug_file
|
|
||||||
let s:debug_file = ''
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:debug_enabled = 1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! tagbar#debug#stop_debug() abort
|
|
||||||
let s:debug_enabled = 0
|
|
||||||
let s:debug_file = ''
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! tagbar#debug#log(msg) abort
|
|
||||||
if s:debug_enabled
|
|
||||||
execute 'redir >> ' . s:debug_file
|
|
||||||
silent echon s:gettime() . ': ' . a:msg . "\n"
|
|
||||||
redir END
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! tagbar#debug#log_ctags_output(output) abort
|
|
||||||
if s:debug_enabled
|
|
||||||
exe 'redir! > ' . s:debug_file . '.ctags_out'
|
|
||||||
silent echon a:output
|
|
||||||
redir END
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! tagbar#debug#enabled() abort
|
|
||||||
return s:debug_enabled
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
if has('reltime')
|
|
||||||
function! s:gettime() abort
|
|
||||||
let time = split(reltimestr(reltime()), '\.')
|
|
||||||
return strftime('%Y-%m-%d %H:%M:%S.', time[0]) . time[1]
|
|
||||||
endfunction
|
|
||||||
else
|
|
||||||
function! s:gettime() abort
|
|
||||||
return strftime('%Y-%m-%d %H:%M:%S')
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:debug_enabled = 0
|
|
||||||
let s:debug_file = ''
|
|
35
bundle/tagbar/autoload/tagbar/log.vim
vendored
Normal file
35
bundle/tagbar/autoload/tagbar/log.vim
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" log.vim --- logger for tagbar
|
||||||
|
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||||
|
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||||
|
" URL: https://spacevim.org
|
||||||
|
" License: GPLv3
|
||||||
|
"=============================================================================
|
||||||
|
|
||||||
|
if exists('s:debug_enabled')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:LOGGER =SpaceVim#logger#derive('tagbar')
|
||||||
|
|
||||||
|
function! tagbar#log#start_debug(...) abort
|
||||||
|
call s:LOGGER.info('enable debug mode!')
|
||||||
|
call s:LOGGER.start_debug()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! tagbar#log#stop_debug() abort
|
||||||
|
call s:LOGGER.info('disable debug mode!')
|
||||||
|
call s:LOGGER.stop_debug()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! tagbar#log#debug(msg) abort
|
||||||
|
call s:LOGGER.debug(a:msg)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! tagbar#log#info(msg) abort
|
||||||
|
call s:LOGGER.info(a:msg)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! tagbar#log#enabled() abort
|
||||||
|
return s:LOGGER.enabled()
|
||||||
|
endfunction
|
12
bundle/tagbar/doc/tagbar.txt
vendored
12
bundle/tagbar/doc/tagbar.txt
vendored
@ -307,15 +307,13 @@ COMMANDS *tagbar-commands*
|
|||||||
makes sense to customize. See |tagbar-extend| for more information about
|
makes sense to customize. See |tagbar-extend| for more information about
|
||||||
type configurations.
|
type configurations.
|
||||||
|
|
||||||
:TagbarDebug [logfile] *:TagbarDebug*
|
:TagbarDebug *:TagbarDebug*
|
||||||
Start debug mode. This will write debug messages to file [logfile] while
|
Start debug mode. This will put debug message to SpaceVim runtime log.
|
||||||
using Tagbar. If no argument is given "tagbardebug.log" in the current
|
which can be found via `SPC h L`
|
||||||
directory is used. Note: an existing file will be overwritten!
|
|
||||||
Note also that it is usually necessary to call this command before loading
|
|
||||||
a file that creates problems in order to get all of the needed data.
|
|
||||||
|
|
||||||
:TagbarDebugEnd *:TagbarDebugEnd*
|
:TagbarDebugEnd *:TagbarDebugEnd*
|
||||||
End debug mode, debug messages will no longer be written to the logfile.
|
End debug mode, debug messages will no longer be written SpaceVim runtime
|
||||||
|
log.
|
||||||
|
|
||||||
:TagbarForceUpdate *:TagbarForceUpdate*
|
:TagbarForceUpdate *:TagbarForceUpdate*
|
||||||
Forcefully update a file even if it exceeds the |g:tagbar_file_size_limit|
|
Forcefully update a file even if it exceeds the |g:tagbar_file_size_limit|
|
||||||
|
4
bundle/tagbar/plugin/tagbar.vim
vendored
4
bundle/tagbar/plugin/tagbar.vim
vendored
@ -193,8 +193,8 @@ command! -nargs=1 -bang TagbarSetFoldlevel call tagbar#SetFoldLevel(<args>, <ba
|
|||||||
command! -nargs=0 TagbarShowTag call tagbar#highlighttag(1, 1)
|
command! -nargs=0 TagbarShowTag call tagbar#highlighttag(1, 1)
|
||||||
command! -nargs=* TagbarCurrentTag echo tagbar#currenttag('%s', 'No current tag', <f-args>)
|
command! -nargs=* TagbarCurrentTag echo tagbar#currenttag('%s', 'No current tag', <f-args>)
|
||||||
command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig(<f-args>)
|
command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig(<f-args>)
|
||||||
command! -nargs=? TagbarDebug call tagbar#debug#start_debug(<f-args>)
|
command! -nargs=0 TagbarDebug call tagbar#log#start_debug()
|
||||||
command! -nargs=0 TagbarDebugEnd call tagbar#debug#stop_debug()
|
command! -nargs=0 TagbarDebugEnd call tagbar#log#stop_debug()
|
||||||
command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause()
|
command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause()
|
||||||
command! -nargs=0 TagbarForceUpdate call tagbar#ForceUpdate()
|
command! -nargs=0 TagbarForceUpdate call tagbar#ForceUpdate()
|
||||||
command! -nargs=0 TagbarJump call tagbar#jump()
|
command! -nargs=0 TagbarJump call tagbar#jump()
|
||||||
|
@ -1645,6 +1645,31 @@ SpaceVim#layers#load({layer}) *SpaceVim#layers#load()*
|
|||||||
\ )
|
\ )
|
||||||
<
|
<
|
||||||
|
|
||||||
|
SpaceVim#logger#info({msg}) *SpaceVim#logger#info()*
|
||||||
|
write message to SpaceVim runtime log with `info` level.
|
||||||
|
|
||||||
|
SpaceVim#logger#derive({name}) *SpaceVim#logger#derive()*
|
||||||
|
Derive a new logger based on SpaceVim's runtime logger. The new logger
|
||||||
|
provides following functions:
|
||||||
|
1. info(msg): like |SpaceVim#logger#info|, but include the derive name.
|
||||||
|
2. warn(msg): like |SpaceVim#logger#warn|
|
||||||
|
3. error(msg): like |SpaceVim#logger#error|
|
||||||
|
4. debug(msg): write debug message run SpaceVim runtime log
|
||||||
|
5. start_debug(): enable debug mode of derived logger.
|
||||||
|
6. stop_debug(): stop debug mode of derived logger.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
>
|
||||||
|
let s:LOGGER = SpaceVim#logger#derive('myplug')
|
||||||
|
|
||||||
|
call s:LOGGER.info('hello world')
|
||||||
|
<
|
||||||
|
|
||||||
|
The this info message will be write to SpaceVim's runtime log:
|
||||||
|
>
|
||||||
|
[ myplug ] [00:02:54:051] [ Info ] hello world
|
||||||
|
<
|
||||||
|
|
||||||
SpaceVim#logger#setLevel({level}) *SpaceVim#logger#setLevel()*
|
SpaceVim#logger#setLevel({level}) *SpaceVim#logger#setLevel()*
|
||||||
Set debug level of SpaceVim. Default is 1.
|
Set debug level of SpaceVim. Default is 1.
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ local M = {
|
|||||||
['temp'] = {},
|
['temp'] = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- 0 : log debug, info, warn, error messages
|
-- 0 : log debug, info, warn, error messages
|
||||||
-- 1 : log info, warn, error messages
|
-- 1 : log info, warn, error messages
|
||||||
-- 2 : log warn, error messages
|
-- 2 : log warn, error messages
|
||||||
@ -36,8 +35,15 @@ function M.set_verbose(vb)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.set_level(l)
|
function M.set_level(l)
|
||||||
|
-- the level only can be:
|
||||||
|
-- 0 : log debug, info, warn, error messages
|
||||||
|
-- 1 : log info, warn, error messages
|
||||||
|
-- 2 : log warn, error messages
|
||||||
|
-- 3 : log error messages
|
||||||
|
if l == 0 or l == 1 or l == 2 or l == 3 then
|
||||||
M.level = l
|
M.level = l
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function M._build_msg(msg, l)
|
function M._build_msg(msg, l)
|
||||||
msg = msg or ''
|
msg = msg or ''
|
||||||
@ -52,11 +58,7 @@ function M._build_msg(msg, l)
|
|||||||
local s = fn.float2nr(clock) % 60
|
local s = fn.float2nr(clock) % 60
|
||||||
local mic = string.format('%00.3f', clock - fn.float2nr(clock))
|
local mic = string.format('%00.3f', clock - fn.float2nr(clock))
|
||||||
local c = string.format('%02d:%02d:%02d:%s', h, m, s, string.sub(mic, 3, -1))
|
local c = string.format('%02d:%02d:%02d:%s', h, m, s, string.sub(mic, 3, -1))
|
||||||
local log = string.format('[ %s ] [%s] [ %s ] %s',
|
local log = string.format('[ %s ] [%s] [ %s ] %s', M.name, c, M.levels[l], msg)
|
||||||
M.name,
|
|
||||||
c,
|
|
||||||
M.levels[l],
|
|
||||||
msg)
|
|
||||||
return log
|
return log
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -92,7 +94,6 @@ function M.write(msg)
|
|||||||
end
|
end
|
||||||
fn.writefile({ msg }, M.file, flags)
|
fn.writefile({ msg }, M.file, flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.warn(msg, ...)
|
function M.warn(msg, ...)
|
||||||
@ -122,19 +123,22 @@ function M.view(l)
|
|||||||
local logs = ''
|
local logs = ''
|
||||||
if fn.filereadable(M.file) == 1 then
|
if fn.filereadable(M.file) == 1 then
|
||||||
logs = fn.readfile(M.file, '')
|
logs = fn.readfile(M.file, '')
|
||||||
info = info .. fn.join(fn.filter(logs, 'self._comp(v:val, a:l)'), "\n")
|
info = info .. fn.join(fn.filter(logs, 'self._comp(v:val, a:l)'), '\n')
|
||||||
else
|
else
|
||||||
info = info .. '[ ' .. M.name .. ' ] : logger file ' .. M.file
|
info = info
|
||||||
|
.. '[ '
|
||||||
|
.. M.name
|
||||||
|
.. ' ] : logger file '
|
||||||
|
.. M.file
|
||||||
.. ' does not exists, only log for current process will be shown!'
|
.. ' does not exists, only log for current process will be shown!'
|
||||||
.. "\n"
|
.. '\n'
|
||||||
for key, value in pairs(M.temp) do
|
for key, value in pairs(M.temp) do
|
||||||
if M._comp(value, l) == 1 then
|
if M._comp(value, l) == 1 then
|
||||||
info = info .. value .. "\n"
|
info = info .. value .. '\n'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return info
|
return info
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M._comp(msg, l)
|
function M._comp(msg, l)
|
||||||
@ -142,9 +146,17 @@ function M._comp(msg, l)
|
|||||||
if string.find(msg, M.levels[2]) ~= nil then
|
if string.find(msg, M.levels[2]) ~= nil then
|
||||||
return 1
|
return 1
|
||||||
elseif string.find(msg, M.levels[1]) ~= nil then
|
elseif string.find(msg, M.levels[1]) ~= nil then
|
||||||
if l > 2 then return 0 else return 1 end
|
if l > 2 then
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
if l > 1 then return 0 else return 1 end
|
return 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if l > 1 then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -160,6 +172,4 @@ function M.set_file(file)
|
|||||||
M.file = file
|
M.file = file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
-- License: GPLv3
|
-- License: GPLv3
|
||||||
--=============================================================================
|
--=============================================================================
|
||||||
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local logger = require('spacevim.api').import('logger')
|
local logger = require('spacevim.api').import('logger')
|
||||||
@ -25,8 +24,6 @@ logger.set_level(1)
|
|||||||
logger.set_silent(1)
|
logger.set_silent(1)
|
||||||
logger.set_verbose(1)
|
logger.set_verbose(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function M.info(msg)
|
function M.info(msg)
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
end
|
end
|
||||||
@ -52,13 +49,12 @@ function M.setOutput(file)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.viewRuntimeLog()
|
function M.viewRuntimeLog()
|
||||||
local info = "### SpaceVim runtime log :\n\n"
|
local info = '### SpaceVim runtime log :\n\n' .. logger.view(logger.level)
|
||||||
.. logger.view(logger.level)
|
|
||||||
cmd('tabnew')
|
cmd('tabnew')
|
||||||
cmd('setl nobuflisted')
|
cmd('setl nobuflisted')
|
||||||
cmd('nnoremap <buffer><silent> q :tabclose!<CR>')
|
cmd('nnoremap <buffer><silent> q :tabclose!<CR>')
|
||||||
-- put info into buffer
|
-- put info into buffer
|
||||||
fn.append(0, fn.split(info, "\n"))
|
fn.append(0, fn.split(info, '\n'))
|
||||||
cmd('setl nomodifiable')
|
cmd('setl nomodifiable')
|
||||||
cmd('setl buftype=nofile')
|
cmd('setl buftype=nofile')
|
||||||
cmd('setl filetype=SpaceVimLog')
|
cmd('setl filetype=SpaceVimLog')
|
||||||
@ -67,22 +63,22 @@ end
|
|||||||
|
|
||||||
function M.viewLog(...)
|
function M.viewLog(...)
|
||||||
local argvs = { ... }
|
local argvs = { ... }
|
||||||
local info = "<details><summary> SpaceVim debug information </summary>\n\n"
|
local info = '<details><summary> SpaceVim debug information </summary>\n\n'
|
||||||
.. "### SpaceVim options :\n\n"
|
.. '### SpaceVim options :\n\n'
|
||||||
.. "```toml\n"
|
.. '```toml\n'
|
||||||
.. fn.join(call('SpaceVim#options#list'), "\n")
|
.. fn.join(call('SpaceVim#options#list'), '\n')
|
||||||
.. "\n```\n"
|
.. '\n```\n'
|
||||||
.. "\n\n"
|
.. '\n\n'
|
||||||
.. "### SpaceVim layers :\n\n"
|
.. '### SpaceVim layers :\n\n'
|
||||||
.. call('SpaceVim#layers#report')
|
.. call('SpaceVim#layers#report')
|
||||||
.. "\n\n"
|
.. '\n\n'
|
||||||
.. "### SpaceVim Health checking :\n\n"
|
.. '### SpaceVim Health checking :\n\n'
|
||||||
.. call('SpaceVim#health#report')
|
.. call('SpaceVim#health#report')
|
||||||
.. "\n\n"
|
.. '\n\n'
|
||||||
.. "### SpaceVim runtime log :\n\n"
|
.. '### SpaceVim runtime log :\n\n'
|
||||||
.. "```log\n"
|
.. '```log\n'
|
||||||
.. logger.view(logger.level)
|
.. logger.view(logger.level)
|
||||||
.. "\n```\n</details>\n\n"
|
.. '\n```\n</details>\n\n'
|
||||||
if argvs ~= nil and #argvs >= 1 then
|
if argvs ~= nil and #argvs >= 1 then
|
||||||
local bang = argvs[1]
|
local bang = argvs[1]
|
||||||
if bang == 1 then
|
if bang == 1 then
|
||||||
@ -90,7 +86,7 @@ function M.viewLog(...)
|
|||||||
cmd('setl nobuflisted')
|
cmd('setl nobuflisted')
|
||||||
cmd('nnoremap <buffer><silent> q :tabclose!<CR>')
|
cmd('nnoremap <buffer><silent> q :tabclose!<CR>')
|
||||||
-- put info into buffer
|
-- put info into buffer
|
||||||
fn.append(0, fn.split(info, "\n"))
|
fn.append(0, fn.split(info, '\n'))
|
||||||
cmd('setl nomodifiable')
|
cmd('setl nomodifiable')
|
||||||
cmd('setl buftype=nofile')
|
cmd('setl buftype=nofile')
|
||||||
cmd('setl filetype=markdown')
|
cmd('setl filetype=markdown')
|
||||||
@ -108,8 +104,11 @@ function M.syntax_extra()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.derive(name)
|
function M.derive(name)
|
||||||
local derive = {}
|
local derive = {
|
||||||
derive['origin_name'] = logger.get_name()
|
origin_name = logger.get_name(),
|
||||||
|
_debug_mode = false,
|
||||||
|
derive_name = fn.printf('%' .. fn.strdisplaywidth(logger.get_name()) .. 'S', name),
|
||||||
|
}
|
||||||
|
|
||||||
function derive.info(msg)
|
function derive.info(msg)
|
||||||
logger.set_name(derive.derive_name)
|
logger.set_name(derive.derive_name)
|
||||||
@ -128,11 +127,22 @@ function M.derive(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function derive.debug(msg)
|
function derive.debug(msg)
|
||||||
|
if derive._debug_mode then
|
||||||
logger.set_name(derive.derive_name)
|
logger.set_name(derive.derive_name)
|
||||||
logger.debug(msg)
|
logger.debug(msg)
|
||||||
logger.set_name(derive.origin_name)
|
logger.set_name(derive.origin_name)
|
||||||
end
|
end
|
||||||
derive['derive_name'] = fn.printf('%' .. fn.strdisplaywidth(logger.get_name()) .. 'S', name)
|
end
|
||||||
|
function derive.start_debug()
|
||||||
|
derive._debug_mode = true
|
||||||
|
end
|
||||||
|
function derive.stop_debug()
|
||||||
|
derive._debug_mode = false
|
||||||
|
end
|
||||||
|
function derive.enabled() -- {{{
|
||||||
|
return derive._debug_mode
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
return derive
|
return derive
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user