diff options
| author | jdhao <jdhao@hotmail.com> | 2021-07-24 14:53:48 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2021-07-24 14:53:48 +0800 |
| commit | f7475f3e4fb01d5a34b0eec3ebff18981e910e87 (patch) | |
| tree | c6df470308f67c4204390a40577788d5de5d6144 /autoload/utils.vim | |
| parent | b0eb7c4508599a7eace480d89e764612664839a3 (diff) | |
Refactor: use a unified log function
Diffstat (limited to 'autoload/utils.vim')
| -rw-r--r-- | autoload/utils.vim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/autoload/utils.vim b/autoload/utils.vim index 9d84c9b..217666b 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -145,3 +145,25 @@ function! utils#Get_titlestr() abort return l:title_str endfunction + +" Log a message using certain highlight group +function! utils#Log(msg, ...) abort + let l:hi = '' + if len(a:000) == 1 + if a:1 ==? 'info' + let l:hi = 'Normal' + elseif a:1 ==? 'warning' + let l:hi = 'WarningMsg' + elseif a:1 ==? 'error' + let l:hi = 'ErrorMsg' + else + echoerr 'Unsupported log level:' a:1 + endif + else + let l:hi = 'Normal' + endif + + execute 'echohl' l:hi + unsilent echomsg a:msg + echohl None +endfunction |
