1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-18 05:35:42 +08:00
2020-06-13 14:06:35 +08:00

50 lines
1.2 KiB
VimL

function! neoformat#utils#log(msg) abort
if neoformat#utils#should_be_verbose()
return s:better_echo(a:msg)
endif
endfunction
function! neoformat#utils#log_file_content(path) abort
if neoformat#utils#should_be_verbose()
return s:better_echo(readfile(a:path))
endif
endfunction
function! neoformat#utils#warn(msg) abort
echohl WarningMsg | call s:better_echo(a:msg) | echohl NONE
endfunction
function! neoformat#utils#msg(msg) abort
if exists('g:neoformat_only_msg_on_error') && g:neoformat_only_msg_on_error
return
endif
return s:better_echo(a:msg)
endfunction
function! neoformat#utils#should_be_verbose() abort
if !exists('g:neoformat_verbose')
let g:neoformat_verbose = 0
endif
return &verbose || g:neoformat_verbose
endfunction
function! s:better_echo(msg) abort
if type(a:msg) != type('')
echom 'Neoformat: ' . string(a:msg)
else
echom 'Neoformat: ' . a:msg
endif
endfunction
function! neoformat#utils#var(name) abort
return neoformat#utils#var_default(a:name, 0)
endfunction
function! neoformat#utils#var_default(name, default) abort
if exists('b:' . a:name)
return get(b:, a:name)
endif
return get(g:, a:name, a:default)
endfunction