Use shiftwidth() instead of &shiftwidth.

This commit is contained in:
Chiel92 2015-10-08 18:15:41 +02:00
parent e68e87b0f9
commit d3d07cb23e
2 changed files with 19 additions and 17 deletions

View File

@ -170,6 +170,8 @@ For the default formatprogram definitions, the options `expandtab`, `shiftwidth`
This means that the formatting style will match your current vim settings as much as possible. This means that the formatting style will match your current vim settings as much as possible.
You can have look look at the exact default definitions for more examples. You can have look look at the exact default definitions for more examples.
They are defined in `vim-autoformat/plugin/defaults.vim`. They are defined in `vim-autoformat/plugin/defaults.vim`.
As a small side note, in the actual defaults the function `shiftwidth()` is used instead of the
property. This is because it falls back to the value of `tabstop` if `shiftwidth` is 0.
If you have a composite filetype with dots (like `django.python` or `php.wordpress`), vim-autoformat internally replaces the dots with underscores so you can specify formatters through `g:formatters_django_python` and so on. If you have a composite filetype with dots (like `django.python` or `php.wordpress`), vim-autoformat internally replaces the dots with underscores so you can specify formatters through `g:formatters_django_python` and so on.

View File

@ -15,7 +15,7 @@ endif
" C# " C#
if !exists('g:formatdef_astyle_cs') if !exists('g:formatdef_astyle_cs')
let g:formatdef_astyle_cs = '"astyle --mode=cs --style=ansi --indent-namespaces -pcH".(&expandtab ? "s".&shiftwidth : "t")' let g:formatdef_astyle_cs = '"astyle --mode=cs --style=ansi --indent-namespaces -pcH".(&expandtab ? "s".shiftwidth() : "t")'
endif endif
if !exists('g:formatters_cs') if !exists('g:formatters_cs')
@ -25,14 +25,14 @@ endif
" Generic C, C++, Objective-C " Generic C, C++, Objective-C
if !exists('g:formatdef_clangformat') if !exists('g:formatdef_clangformat')
let g:formatdef_clangformat = "'clang-format -lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=\"{BasedOnStyle: WebKit, AlignTrailingComments: true, '.(&textwidth ? 'ColumnLimit: '.&textwidth.', ' : '').(&expandtab ? 'UseTab: Never, IndentWidth: '.&shiftwidth : 'UseTab: Always').'}\"'" let g:formatdef_clangformat = "'clang-format -lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=\"{BasedOnStyle: WebKit, AlignTrailingComments: true, '.(&textwidth ? 'ColumnLimit: '.&textwidth.', ' : '').(&expandtab ? 'UseTab: Never, IndentWidth: '.shiftwidth() : 'UseTab: Always').'}\"'"
endif endif
" C " C
if !exists('g:formatdef_astyle_c') if !exists('g:formatdef_astyle_c')
let g:formatdef_astyle_c = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".&shiftwidth : "t")' let g:formatdef_astyle_c = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")'
endif endif
if !exists('g:formatters_c') if !exists('g:formatters_c')
@ -42,7 +42,7 @@ endif
" C++ " C++
if !exists('g:formatdef_astyle_cpp') if !exists('g:formatdef_astyle_cpp')
let g:formatdef_astyle_cpp = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".&shiftwidth : "t")' let g:formatdef_astyle_cpp = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")'
endif endif
if !exists('g:formatters_cpp') if !exists('g:formatters_cpp')
@ -58,7 +58,7 @@ endif
" Java " Java
if !exists('g:formatdef_astyle_java') if !exists('g:formatdef_astyle_java')
let g:formatdef_astyle_java = '"astyle --mode=java --style=ansi -pcH".(&expandtab ? "s".&shiftwidth : "t")' let g:formatdef_astyle_java = '"astyle --mode=java --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")'
endif endif
if !exists('g:formatters_java') if !exists('g:formatters_java')
@ -68,11 +68,11 @@ endif
" Javascript " Javascript
if !exists('g:formatdef_jsbeautify_javascript') if !exists('g:formatdef_jsbeautify_javascript')
let g:formatdef_jsbeautify_javascript = '"js-beautify -f - -".(&expandtab ? "s ".&shiftwidth : "t").(&textwidth ? " -w ".&textwidth : "")' let g:formatdef_jsbeautify_javascript = '"js-beautify -f - -".(&expandtab ? "s ".shiftwidth() : "t").(&textwidth ? " -w ".&textwidth : "")'
endif endif
if !exists('g:formatdef_pyjsbeautify_javascript') if !exists('g:formatdef_pyjsbeautify_javascript')
let g:formatdef_pyjsbeautify_javascript = '"js-beautify -".(&expandtab ? "s ".&shiftwidth : "t").(&textwidth ? " -w ".&textwidth : "")." -"' let g:formatdef_pyjsbeautify_javascript = '"js-beautify -".(&expandtab ? "s ".shiftwidth() : "t").(&textwidth ? " -w ".&textwidth : "")." -"'
endif endif
if !exists('g:formatdef_jscs') if !exists('g:formatdef_jscs')
@ -90,11 +90,11 @@ endif
" JSON " JSON
if !exists('g:formatdef_jsbeautify_json') if !exists('g:formatdef_jsbeautify_json')
let g:formatdef_jsbeautify_json = '"js-beautify -f - -".(&expandtab ? "s ".&shiftwidth : "t")' let g:formatdef_jsbeautify_json = '"js-beautify -f - -".(&expandtab ? "s ".shiftwidth() : "t")'
endif endif
if !exists('g:formatdef_pyjsbeautify_json') if !exists('g:formatdef_pyjsbeautify_json')
let g:formatdef_pyjsbeautify_json = '"js-beautify -".(&expandtab ? "s ".&shiftwidth : "t")." -"' let g:formatdef_pyjsbeautify_json = '"js-beautify -".(&expandtab ? "s ".shiftwidth() : "t")." -"'
endif endif
if !exists('g:formatters_json') if !exists('g:formatters_json')
@ -107,11 +107,11 @@ endif
" HTML " HTML
if !exists('g:formatdef_htmlbeautify') if !exists('g:formatdef_htmlbeautify')
let g:formatdef_htmlbeautify = '"html-beautify -f - -s ".&shiftwidth' let g:formatdef_htmlbeautify = '"html-beautify -f - -s ".shiftwidth()'
endif endif
if !exists('g:formatdef_tidy_html') if !exists('g:formatdef_tidy_html')
let g:formatdef_tidy_html = '"tidy -q --show-errors 0 --show-warnings 0 --force-output --indent auto --indent-spaces ".&shiftwidth." --vertical-space yes --tidy-mark no -wrap ".&textwidth' let g:formatdef_tidy_html = '"tidy -q --show-errors 0 --show-warnings 0 --force-output --indent auto --indent-spaces ".shiftwidth()." --vertical-space yes --tidy-mark no -wrap ".&textwidth'
endif endif
if !exists('g:formatters_html') if !exists('g:formatters_html')
@ -122,7 +122,7 @@ endif
" XML " XML
if !exists('g:formatdef_tidy_xml') if !exists('g:formatdef_tidy_xml')
let g:formatdef_tidy_xml = '"tidy -q -xml --show-errors 0 --show-warnings 0 --force-output --indent auto --indent-spaces ".&shiftwidth." --vertical-space yes --tidy-mark no -wrap ".&textwidth' let g:formatdef_tidy_xml = '"tidy -q -xml --show-errors 0 --show-warnings 0 --force-output --indent auto --indent-spaces ".shiftwidth()." --vertical-space yes --tidy-mark no -wrap ".&textwidth'
endif endif
if !exists('g:formatters_xml') if !exists('g:formatters_xml')
@ -132,7 +132,7 @@ endif
" XHTML " XHTML
if !exists('g:formatdef_tidy_xhtml') if !exists('g:formatdef_tidy_xhtml')
let g:formatdef_tidy_xhtml = '"tidy -q --show-errors 0 --show-warnings 0 --force-output --indent auto --indent-spaces ".&shiftwidth." --vertical-space yes --tidy-mark no -asxhtml -wrap ".&textwidth' let g:formatdef_tidy_xhtml = '"tidy -q --show-errors 0 --show-warnings 0 --force-output --indent auto --indent-spaces ".shiftwidth()." --vertical-space yes --tidy-mark no -asxhtml -wrap ".&textwidth'
endif endif
if !exists('g:formatters_xhtml') if !exists('g:formatters_xhtml')
@ -141,7 +141,7 @@ endif
" Ruby " Ruby
if !exists('g:formatdef_rbeautify') if !exists('g:formatdef_rbeautify')
let g:formatdef_rbeautify = '"rbeautify ".(&expandtab ? "-s -c ".&shiftwidth : "-t")' let g:formatdef_rbeautify = '"rbeautify ".(&expandtab ? "-s -c ".shiftwidth() : "-t")'
endif endif
if !exists('g:formatters_ruby') if !exists('g:formatters_ruby')
@ -151,7 +151,7 @@ endif
" CSS " CSS
if !exists('g:formatdef_cssbeautify') if !exists('g:formatdef_cssbeautify')
let g:formatdef_cssbeautify = '"css-beautify -f - -s ".&shiftwidth' let g:formatdef_cssbeautify = '"css-beautify -f - -s ".shiftwidth()'
endif endif
if !exists('g:formatters_css') if !exists('g:formatters_css')
@ -161,7 +161,7 @@ endif
" SCSS " SCSS
if !exists('g:formatdef_sassconvert') if !exists('g:formatdef_sassconvert')
let g:formatdef_sassconvert = '"sass-convert -F scss -T scss --indent " . (&expandtab ? &shiftwidth : "t")' let g:formatdef_sassconvert = '"sass-convert -F scss -T scss --indent " . (&expandtab ? shiftwidth() : "t")'
endif endif
if !exists('g:formatters_scss') if !exists('g:formatters_scss')
@ -183,7 +183,7 @@ endif
" Two definitions are provided for two versions of gofmt. " Two definitions are provided for two versions of gofmt.
" See issue #59 " See issue #59
if !exists('g:formatdef_gofmt_1') if !exists('g:formatdef_gofmt_1')
let g:formatdef_gofmt_1 = '"gofmt -tabs=".(&expandtab ? "false" : "true")." -tabwidth=".&shiftwidth' let g:formatdef_gofmt_1 = '"gofmt -tabs=".(&expandtab ? "false" : "true")." -tabwidth=".shiftwidth()'
endif endif
if !exists('g:formatdef_gofmt_2') if !exists('g:formatdef_gofmt_2')