diff --git a/autoload/SpaceVim/api/vim/buffer.vim b/autoload/SpaceVim/api/vim/buffer.vim index f06ee02d4..9a395f356 100644 --- a/autoload/SpaceVim/api/vim/buffer.vim +++ b/autoload/SpaceVim/api/vim/buffer.vim @@ -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 diff --git a/autoload/SpaceVim/custom.vim b/autoload/SpaceVim/custom.vim index ce9000f6b..974361a51 100644 --- a/autoload/SpaceVim/custom.vim +++ b/autoload/SpaceVim/custom.vim @@ -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') diff --git a/autoload/SpaceVim/layers/checkers.vim b/autoload/SpaceVim/layers/checkers.vim index 94398d95f..9beeae409 100644 --- a/autoload/SpaceVim/layers/checkers.vim +++ b/autoload/SpaceVim/layers/checkers.vim @@ -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' diff --git a/autoload/SpaceVim/layers/denite.vim b/autoload/SpaceVim/layers/denite.vim index ca97cd9b5..26d6664f5 100644 --- a/autoload/SpaceVim/layers/denite.vim +++ b/autoload/SpaceVim/layers/denite.vim @@ -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 diff --git a/autoload/SpaceVim/logger.vim b/autoload/SpaceVim/logger.vim index 76fc5ecb3..f934cf500 100644 --- a/autoload/SpaceVim/logger.vim +++ b/autoload/SpaceVim/logger.vim @@ -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( diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 822ae5120..7ad35ec21 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -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. diff --git a/lua/spacevim/api/logger.lua b/lua/spacevim/api/logger.lua index a7e62ae9a..6ac250649 100644 --- a/lua/spacevim/api/logger.lua +++ b/lua/spacevim/api/logger.lua @@ -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')