mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 20:20:05 +08:00
fix(logger): silent warn by default
This commit is contained in:
parent
2cf2f0a987
commit
6388258786
@ -312,7 +312,7 @@ function! s:self.add_highlight(bufnr, hl, line, col, long) abort
|
|||||||
if exists('*nvim_buf_add_highlight')
|
if exists('*nvim_buf_add_highlight')
|
||||||
call nvim_buf_add_highlight(a:bufnr, 0, a:hl, a:line, a:col, a:col + a:long)
|
call nvim_buf_add_highlight(a:bufnr, 0, a:hl, a:line, a:col, a:col + a:long)
|
||||||
else
|
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
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:set(key,val) abort
|
function! s:set(key,val) abort
|
||||||
if !exists('g:spacevim_' . a:key)
|
if !exists('g:spacevim_' . a:key)
|
||||||
call SpaceVim#logger#warn('unsupported option: ' . a:key, 0)
|
call SpaceVim#logger#warn('unsupported option: ' . a:key)
|
||||||
else
|
else
|
||||||
exe 'let ' . 'g:spacevim_' . a:key . '=' . a:val
|
exe 'let ' . 'g:spacevim_' . a:key . '=' . a:val
|
||||||
endif
|
endif
|
||||||
@ -77,7 +77,7 @@ function! s:write_to_config(config) abort
|
|||||||
let g:_spacevim_global_config_path = global_dir . 'init.toml'
|
let g:_spacevim_global_config_path = global_dir . 'init.toml'
|
||||||
let cf = global_dir . 'init.toml'
|
let cf = global_dir . 'init.toml'
|
||||||
if filereadable(cf)
|
if filereadable(cf)
|
||||||
call SpaceVim#logger#warn('The file already exists:' . cf, 0)
|
call SpaceVim#logger#warn('The file already exists:' . cf)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let dir = expand(fnamemodify(cf, ':p:h'))
|
let dir = expand(fnamemodify(cf, ':p:h'))
|
||||||
@ -157,7 +157,7 @@ function! s:apply(config, type) abort
|
|||||||
for [name, value] in items(options)
|
for [name, value] in items(options)
|
||||||
if name ==# 'filemanager'
|
if name ==# 'filemanager'
|
||||||
if value ==# 'defx' && !has('python3')
|
if value ==# 'defx' && !has('python3')
|
||||||
call SpaceVim#logger#warn('defx requires +python3!', 0)
|
call SpaceVim#logger#warn('defx requires +python3!')
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
" keep backward compatibility
|
" keep backward compatibility
|
||||||
@ -200,7 +200,7 @@ function! s:apply(config, type) abort
|
|||||||
elseif has_key(plugin, 'name')
|
elseif has_key(plugin, 'name')
|
||||||
call add(g:spacevim_custom_plugins, [plugin.name, plugin])
|
call add(g:spacevim_custom_plugins, [plugin.name, plugin])
|
||||||
else
|
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))
|
call SpaceVim#logger#info(string(plugin))
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -321,7 +321,7 @@ function! s:load_local_conf() abort
|
|||||||
call writefile([s:JSON.json_encode(conf)], local_conf_cache)
|
call writefile([s:JSON.json_encode(conf)], local_conf_cache)
|
||||||
call s:apply(conf, 'local')
|
call s:apply(conf, 'local')
|
||||||
catch
|
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
|
endtry
|
||||||
endif
|
endif
|
||||||
elseif filereadable('.SpaceVim.d/init.vim')
|
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 writefile([s:JSON.json_encode(conf)], global_config_cache)
|
||||||
call s:apply(conf, 'glob')
|
call s:apply(conf, 'glob')
|
||||||
catch
|
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
|
endtry
|
||||||
endif
|
endif
|
||||||
elseif filereadable(global_dir . 'init.vim')
|
elseif filereadable(global_dir . 'init.vim')
|
||||||
|
@ -49,8 +49,8 @@ function! SpaceVim#layers#checkers#plugins() abort
|
|||||||
let plugins = []
|
let plugins = []
|
||||||
|
|
||||||
if exists('g:spacevim_enable_neomake') || exists('g:spacevim_enable_ale')
|
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('enable_neomake and enable_ale is duplecated')
|
||||||
call SpaceVim#logger#warn('please read :h spacevim-options-lint_engine for more info!', 0)
|
call SpaceVim#logger#warn('please read :h spacevim-options-lint_engine for more info!')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:spacevim_lint_engine ==# 'neomake'
|
if g:spacevim_lint_engine ==# 'neomake'
|
||||||
|
@ -307,7 +307,7 @@ function! SpaceVim#layers#denite#loadable()
|
|||||||
if s:CMP.has('python3')
|
if s:CMP.has('python3')
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
call SpaceVim#logger#warn('denite layer requires +python3 enabled!', 0)
|
call SpaceVim#logger#warn('denite layer requires +python3 enabled!')
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
call SpaceVim#logger#info(' use `pip3 install pynvim` to enabled +python3 for neovim.')
|
call SpaceVim#logger#info(' use `pip3 install pynvim` to enabled +python3 for neovim.')
|
||||||
endif
|
endif
|
||||||
|
@ -16,6 +16,9 @@ if has('nvim-0.5.0')
|
|||||||
endfunction
|
endfunction
|
||||||
""
|
""
|
||||||
" 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.
|
||||||
function! SpaceVim#logger#warn(msg, ...) abort
|
function! SpaceVim#logger#warn(msg, ...) abort
|
||||||
let issilent = get(a:000, 0, 1)
|
let issilent = get(a:000, 0, 1)
|
||||||
lua require("spacevim.logger").warn(
|
lua require("spacevim.logger").warn(
|
||||||
|
@ -1649,7 +1649,9 @@ SpaceVim#logger#info({msg}) *SpaceVim#logger#info()*
|
|||||||
write message to SpaceVim runtime log with `info` level.
|
write message to SpaceVim runtime log with `info` level.
|
||||||
|
|
||||||
SpaceVim#logger#warn({msg}) *SpaceVim#logger#warn()*
|
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()*
|
SpaceVim#logger#error({msg}) *SpaceVim#logger#error()*
|
||||||
write error message to spacevim runtime log.
|
write error message to spacevim runtime log.
|
||||||
|
@ -99,7 +99,7 @@ end
|
|||||||
function M.warn(msg, ...)
|
function M.warn(msg, ...)
|
||||||
if M.level <= 2 then
|
if M.level <= 2 then
|
||||||
local log = M._build_msg(msg, 2)
|
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('echohl WarningMsg')
|
||||||
cmd('echom "' .. log .. '"')
|
cmd('echom "' .. log .. '"')
|
||||||
cmd('echohl None')
|
cmd('echohl None')
|
||||||
|
Loading…
Reference in New Issue
Block a user