Take &verbose variable into account. Fix #48.
This commit is contained in:
parent
84f8c1864f
commit
c16a053519
@ -4,6 +4,9 @@ function! s:set_formatprg(...)
|
||||
" Support composite filetypes by replacing dots with underscores
|
||||
let type = substitute(type, "[.]", "_", "g")
|
||||
|
||||
" Detect verbosity
|
||||
let s:verbose = &verbose || exists("g:autoformat_verbosemode")
|
||||
|
||||
" Get formatprg config
|
||||
let s:formatprg_var = "g:formatprg_".type
|
||||
let s:formatprg_args_var = "g:formatprg_args_".type
|
||||
@ -11,7 +14,7 @@ function! s:set_formatprg(...)
|
||||
|
||||
if !exists(s:formatprg_var)
|
||||
" No formatprg defined
|
||||
if exists("g:autoformat_verbosemode")
|
||||
if s:verbose
|
||||
echoerr "No formatter defined for filetype '".type."'."
|
||||
endif
|
||||
return 0
|
||||
@ -28,7 +31,7 @@ function! s:set_formatprg(...)
|
||||
" Set correct formatprg path, if it is installed
|
||||
if !executable(s:formatprg)
|
||||
" Configured formatprg not installed
|
||||
if exists("g:autoformat_verbosemode")
|
||||
if s:verbose
|
||||
echoerr "Defined formatter ".eval(s:formatprg_var)." is not executable."
|
||||
endif
|
||||
return 0
|
||||
@ -38,7 +41,7 @@ function! s:set_formatprg(...)
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"set right formatprg before formatting
|
||||
" Set right formatprg before formatting
|
||||
noremap <expr> gq <SID>set_formatprg() ? 'gq' : 'gq'
|
||||
|
||||
" Function for formatting the entire buffer
|
||||
|
Loading…
Reference in New Issue
Block a user