1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:30:05 +08:00

fix(logger): silent warn by default

This commit is contained in:
wsdjeg 2023-04-14 21:18:35 +08:00
parent 2cf2f0a987
commit 6388258786
7 changed files with 17 additions and 12 deletions

View File

@ -312,7 +312,7 @@ function! s:self.add_highlight(bufnr, hl, line, col, long) abort
if exists('*nvim_buf_add_highlight')
call nvim_buf_add_highlight(a:bufnr, 0, a:hl, a:line, a:col, a:col + a:long)
else
call SpaceVim#logger#warn('vim#buffer.add_highlight api only support neovim', 0)
call SpaceVim#logger#warn('vim#buffer.add_highlight api only support neovim')
endif
endfunction

View File

@ -21,7 +21,7 @@ endfunction
function! s:set(key,val) abort
if !exists('g:spacevim_' . a:key)
call SpaceVim#logger#warn('unsupported option: ' . a:key, 0)
call SpaceVim#logger#warn('unsupported option: ' . a:key)
else
exe 'let ' . 'g:spacevim_' . a:key . '=' . a:val
endif
@ -77,7 +77,7 @@ function! s:write_to_config(config) abort
let g:_spacevim_global_config_path = global_dir . 'init.toml'
let cf = global_dir . 'init.toml'
if filereadable(cf)
call SpaceVim#logger#warn('The file already exists:' . cf, 0)
call SpaceVim#logger#warn('The file already exists:' . cf)
return
endif
let dir = expand(fnamemodify(cf, ':p:h'))
@ -157,7 +157,7 @@ function! s:apply(config, type) abort
for [name, value] in items(options)
if name ==# 'filemanager'
if value ==# 'defx' && !has('python3')
call SpaceVim#logger#warn('defx requires +python3!', 0)
call SpaceVim#logger#warn('defx requires +python3!')
continue
endif
" keep backward compatibility
@ -200,7 +200,7 @@ function! s:apply(config, type) abort
elseif has_key(plugin, 'name')
call add(g:spacevim_custom_plugins, [plugin.name, plugin])
else
call SpaceVim#logger#warn('custom_plugins should contains repo key!', 0)
call SpaceVim#logger#warn('custom_plugins should contains repo key!')
call SpaceVim#logger#info(string(plugin))
endif
endfor
@ -321,7 +321,7 @@ function! s:load_local_conf() abort
call writefile([s:JSON.json_encode(conf)], local_conf_cache)
call s:apply(conf, 'local')
catch
call SpaceVim#logger#warn('failed to load local config:' . v:errmsg, 0)
call SpaceVim#logger#warn('failed to load local config:' . v:errmsg)
endtry
endif
elseif filereadable('.SpaceVim.d/init.vim')
@ -364,7 +364,7 @@ function! s:load_glob_conf() abort
call writefile([s:JSON.json_encode(conf)], global_config_cache)
call s:apply(conf, 'glob')
catch
call SpaceVim#logger#warn('failed to load global config:' . v:errmsg, 0)
call SpaceVim#logger#warn('failed to load global config:' . v:errmsg)
endtry
endif
elseif filereadable(global_dir . 'init.vim')

View File

@ -49,8 +49,8 @@ function! SpaceVim#layers#checkers#plugins() abort
let plugins = []
if exists('g:spacevim_enable_neomake') || exists('g:spacevim_enable_ale')
call SpaceVim#logger#warn('enable_neomake and enable_ale is duplecated', 0)
call SpaceVim#logger#warn('please read :h spacevim-options-lint_engine for more info!', 0)
call SpaceVim#logger#warn('enable_neomake and enable_ale is duplecated')
call SpaceVim#logger#warn('please read :h spacevim-options-lint_engine for more info!')
endif
if g:spacevim_lint_engine ==# 'neomake'

View File

@ -307,7 +307,7 @@ function! SpaceVim#layers#denite#loadable()
if s:CMP.has('python3')
return 1
else
call SpaceVim#logger#warn('denite layer requires +python3 enabled!', 0)
call SpaceVim#logger#warn('denite layer requires +python3 enabled!')
if has('nvim')
call SpaceVim#logger#info(' use `pip3 install pynvim` to enabled +python3 for neovim.')
endif

View File

@ -16,6 +16,9 @@ if has('nvim-0.5.0')
endfunction
""
" write warning message to spacevim runtime log.
" by default, the warning message will not be printed in cmdline, if
" `silent` is set, and is `0`, the warning message will be printed to
" cmdline.
function! SpaceVim#logger#warn(msg, ...) abort
let issilent = get(a:000, 0, 1)
lua require("spacevim.logger").warn(

View File

@ -1649,7 +1649,9 @@ SpaceVim#logger#info({msg}) *SpaceVim#logger#info()*
write message to SpaceVim runtime log with `info` level.
SpaceVim#logger#warn({msg}) *SpaceVim#logger#warn()*
write warning message to spacevim runtime log.
write warning message to spacevim runtime log. by default, the warning
message will not be printed in cmdline, if `silent` is set, and is `0`, the
warning message will be printed to cmdline.
SpaceVim#logger#error({msg}) *SpaceVim#logger#error()*
write error message to spacevim runtime log.

View File

@ -99,7 +99,7 @@ end
function M.warn(msg, ...)
if M.level <= 2 then
local log = M._build_msg(msg, 2)
if (M.silent == 0 and M.verbose >= 2) or select(1, ...) == 1 then
if (M.silent == 0 and M.verbose >= 2) or select(1, ...) == 0 then
cmd('echohl WarningMsg')
cmd('echom "' .. log .. '"')
cmd('echohl None')