From 53e568dab38454eb37875cd5680e8140467f9cb2 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 14 Jun 2023 22:25:29 +0800 Subject: [PATCH] perf(tagbar): use tagbar logger for warning msg --- bundle/tagbar/autoload/tagbar.vim | 4 ++-- bundle/tagbar/autoload/tagbar/log.vim | 6 ++++++ bundle/tagbar/plugin/tagbar.vim | 17 ++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/bundle/tagbar/autoload/tagbar.vim b/bundle/tagbar/autoload/tagbar.vim index ec3921ebf..327210e3e 100644 --- a/bundle/tagbar/autoload/tagbar.vim +++ b/bundle/tagbar/autoload/tagbar.vim @@ -29,7 +29,7 @@ if exists(':Tagbar') == 0 endif if exists(':Tagbar') == 0 - echomsg 'Tagbar: Could not load plugin code, check your runtimepath!' + call tagbar#log#warn('Could not load plugin code, check your runtimepath!') finish endif @@ -39,7 +39,7 @@ redir => s:ftype_out silent filetype redir END if s:ftype_out !~# 'detection:ON' - echomsg 'Tagbar: Filetype detection is turned off, skipping plugin' + call tagbar#log#warn('Filetype detection is turned off, skipping plugin') unlet s:ftype_out finish endif diff --git a/bundle/tagbar/autoload/tagbar/log.vim b/bundle/tagbar/autoload/tagbar/log.vim index 6cea1c527..1064af680 100644 --- a/bundle/tagbar/autoload/tagbar/log.vim +++ b/bundle/tagbar/autoload/tagbar/log.vim @@ -32,6 +32,12 @@ function! tagbar#log#info(msg) abort call s:LOGGER.info(a:msg) endfunction +function! tagbar#log#warn(msg) abort + + call s:LOGGER.warn(a:msg) + +endfunction + function! tagbar#log#debug_enabled() abort return s:LOGGER.debug_enabled() endfunction diff --git a/bundle/tagbar/plugin/tagbar.vim b/bundle/tagbar/plugin/tagbar.vim index fa10ed136..fff757a39 100644 --- a/bundle/tagbar/plugin/tagbar.vim +++ b/bundle/tagbar/plugin/tagbar.vim @@ -27,18 +27,14 @@ endif " Basic init {{{1 if v:version < 700 - echohl WarningMsg - echomsg 'Tagbar: Vim version is too old, Tagbar requires at least 7.0' - echohl None + call tagbar#log#warn('Vim version is too old, Tagbar requires at least 7.0') finish endif if v:version == 700 && !has('patch167') - echohl WarningMsg - echomsg 'Tagbar: Vim versions lower than 7.0.167 have a bug' - \ 'that prevents this version of Tagbar from working.' - \ 'Please use the alternate version posted on the website.' - echohl None + call tagbar#log#warn('Vim versions lower than 7.0.167 have a bug') + call tagbar#log#warn('that prevents this version of Tagbar from working.') + call tagbar#log#warn('Please use the alternate version posted on the website.') finish endif @@ -183,7 +179,6 @@ augroup TagbarSession autocmd SessionLoadPost * nested call tagbar#RestoreSession() augroup END -" Commands {{{1 command! -nargs=? Tagbar call tagbar#ToggleWindow() command! -nargs=? TagbarToggle call tagbar#ToggleWindow() command! -nargs=? TagbarOpen call tagbar#OpenWindow() @@ -200,7 +195,3 @@ command! -nargs=0 TagbarForceUpdate call tagbar#ForceUpdate() command! -nargs=0 TagbarJump call tagbar#jump() command! -nargs=0 TagbarJumpPrev call tagbar#jumpToNearbyTag(-1) command! -nargs=0 TagbarJumpNext call tagbar#jumpToNearbyTag(1) - - -" Modeline {{{1 -" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1