This commit is contained in:
Chiel ten Brinke 2017-06-26 09:29:22 +02:00
parent 889665717c
commit f65c4c88af
2 changed files with 16 additions and 7 deletions

View File

@ -224,7 +224,7 @@ Here is a list of formatprograms that are supported by default, and thus will be
* `fprettify` for modern __Fortran__.
Download from [official repository](https://github.com/pseewald/fprettify). Install with `./setup.py install` or `./setup.py install --user`.
## It doesn't work!
## Help, the formatter doesn't work as expected!
If you're struggling with getting a formatter to work, it may help to set vim-autoformat in
verbose-mode. Vim-autoformat will then output errors on formatters that failed.
@ -238,6 +238,13 @@ let verbose=1
To read all messages in a vim session type `:messages`. Since one cannot always easily copy
the contents of messages (e.g. for posting it in an issue), vim-autoformats command `:PutMessages` may
help. It puts the messages in the current buffer, allowing you to do whatever you want.
#### Reporting bugs
Please report bugs by creating an issue in this repository.
When there are problems with getting a certain formatter to work, provide the output of verbose
mode in the issue.
## How can I change the behaviour of formatters, or add one myself?
If you need a formatter that is not among the defaults, or if you are not satisfied with the default formatting behaviour that is provided by vim-autoformat, you can define it yourself.

View File

@ -105,6 +105,11 @@ function! s:TryAllFormatters(...) range
" once for getting the final expression
let b:formatprg = eval(eval(formatdef_var))
if verbose
echomsg "Trying definition from ".formatdef_var
echomsg "Evaluated formatprg: ".b:formatprg
endif
" Detect if +python or +python3 is available, and call the corresponding function
if !has("python") && !has("python3")
echohl WarningMsg |
@ -209,8 +214,7 @@ stdoutdata, stderrdata = p.communicate(text)
if stderrdata:
if verbose:
formattername = vim.eval('b:formatters[s:index]')
print('Formatter {} has errors: {} Skipping.'.format(formattername, stderrdata))
print('Failing config: {}'.format(repr(formatprg), stderrdata))
print('Formatter {} has errors: {}'.format(formattername, stderrdata))
vim.command('return 1')
else:
# It is not certain what kind of line endings are being used by the format program.
@ -265,12 +269,10 @@ else:
if stderrdata:
if verbose:
formattername = vim.eval('b:formatters[s:index]')
print('Formatter {} has errors: {} Skipping.'.format(formattername, stderrdata))
print('Failing config: {}'.format(repr(formatprg), stderrdata))
print('Formatter {} has errors: {}'.format(formattername, stderrdata))
elif not stdoutdata:
if verbose:
print('Formatter {} gives empty result: {} Skipping.'.format(formattername, stderrdata))
print('Failing config: {}'.format(repr(formatprg), stderrdata))
print('Formatter {} gives empty result: {}'.format(formattername, stderrdata))
else:
# It is not certain what kind of line endings are being used by the format program.
# Therefore we simply split on all possible eol characters.