Add shfmt as a default formatter for shell files

Taking into account vim indentation style dynamically (shiftwidth or
tabs).
This commit is contained in:
Cimbali 2018-01-15 15:39:08 +01:00
parent 5661686e75
commit 18d5938363
2 changed files with 12 additions and 0 deletions

View File

@ -235,6 +235,9 @@ Here is a list of formatprograms that are supported by default, and thus will be
It is a JSON file fixer/formatter for humans using (relaxed) JSON5. It fixes various failures while humans writing JSON and formats JSON codes.
It can be installed with `npm install -g fixjson`. More info is available at https://github.com/rhysd/fixjson.
* `shfmt` for __Shell__.
A shell formatter written in Go supporting POSIX Shell, Bash and mksh that can be installed with `go get -u mvdan.cc/sh/cmd/shfmt`. See https://github.com/mvdan/sh for more info.
## Help, the formatter doesn't work as expected!

View File

@ -453,3 +453,12 @@ endif
if !exists('g:formatters_elixir')
let g:formatters_elixir = ['mix_format']
endif
" Shell
if !exists('g:formatdef_shfmt')
let g:formatdef_shfmt = '"shfmt -i ".(&expandtab ? shiftwidth() : "0")'
endif
if !exists('g:formatters_sh')
let g:formatters_sh = ['shfmt']
endif