2015-05-23 08:25:29 -04:00
|
|
|
"
|
|
|
|
" This file contains all default format program definitions and links them to filetypes
|
|
|
|
"
|
2015-05-23 04:02:05 -04:00
|
|
|
|
2015-05-23 08:25:29 -04:00
|
|
|
|
|
|
|
" Python
|
2015-05-30 06:12:06 -04:00
|
|
|
let g:formatdef_autopep8 = '"autopep8 - --range ".a:firstline." ".a:lastline." ".(&textwidth ? "--max-line-length=".&textwidth : "")'
|
2015-05-23 08:25:29 -04:00
|
|
|
if !exists('g:formatters_python')
|
2015-08-01 00:35:59 -04:00
|
|
|
let g:formatters_python = ['autopep8']
|
2015-05-23 04:02:05 -04:00
|
|
|
endif
|
|
|
|
|
2013-03-09 05:52:11 -05:00
|
|
|
|
2015-05-23 08:25:29 -04:00
|
|
|
" C#
|
|
|
|
let g:formatdef_astyle_cs = '"astyle --mode=cs --style=ansi --indent-namespaces -pcH".(&expandtab ? "s".&shiftwidth : "t")'
|
|
|
|
if !exists('g:formatters_cs')
|
|
|
|
let g:formatters_cs = ['astyle_cs']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2015-05-30 05:02:07 -04:00
|
|
|
" Generic C, C++, Objective-C
|
2015-05-30 06:12:06 -04:00
|
|
|
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').'}\"'"
|
2015-05-30 05:02:07 -04:00
|
|
|
|
|
|
|
|
2015-05-23 08:25:29 -04:00
|
|
|
" C
|
|
|
|
let g:formatdef_astyle_c = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".&shiftwidth : "t")'
|
|
|
|
if !exists('g:formatters_c')
|
2015-05-30 05:02:07 -04:00
|
|
|
let g:formatters_c = ['clangformat', 'astyle_c']
|
2015-05-23 08:25:29 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" C++
|
|
|
|
let g:formatdef_astyle_cpp = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".&shiftwidth : "t")'
|
|
|
|
if !exists('g:formatters_cpp')
|
2015-05-30 05:02:07 -04:00
|
|
|
let g:formatters_cpp = ['clangformat', 'astyle_cpp']
|
2015-05-23 08:25:29 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" Objective C
|
|
|
|
if !exists('g:formatters_objc')
|
2015-05-30 05:02:07 -04:00
|
|
|
let g:formatters_objc = ['clangformat']
|
2015-05-23 08:25:29 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" Java
|
|
|
|
let g:formatdef_astyle_java = '"astyle --mode=java --style=ansi -pcH".(&expandtab ? "s".&shiftwidth : "t")'
|
|
|
|
if !exists('g:formatters_java')
|
|
|
|
let g:formatters_java = ['astyle_java']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" Javascript
|
|
|
|
let g:formatdef_jsbeautify_javascript = '"js-beautify -f - -".(&expandtab ? "s ".&shiftwidth : "t").(&textwidth ? " -w ".&textwidth : "")'
|
2015-05-30 10:18:30 -04:00
|
|
|
let g:formatdef_pyjsbeautify_javascript = '"js-beautify -".(&expandtab ? "s ".&shiftwidth : "t").(&textwidth ? " -w ".&textwidth : "")." -"'
|
2015-05-20 09:05:56 -04:00
|
|
|
let g:formatdef_jscs = '"jscs -x"'
|
2015-05-23 08:25:29 -04:00
|
|
|
if !exists('g:formatters_javascript')
|
2015-05-20 08:56:29 -04:00
|
|
|
let g:formatters_javascript = [
|
|
|
|
\ 'jsbeautify_javascript',
|
2015-05-30 10:11:37 -04:00
|
|
|
\ 'pyjsbeautify_javascript',
|
2015-05-20 08:56:29 -04:00
|
|
|
\ 'jscs'
|
|
|
|
\ ]
|
2015-05-23 08:25:29 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" JSON
|
|
|
|
let g:formatdef_jsbeautify_json = '"js-beautify -f - -".(&expandtab ? "s ".&shiftwidth : "t")'
|
2015-05-31 14:58:14 -04:00
|
|
|
let g:formatdef_pyjsbeautify_json = '"js-beautify -".(&expandtab ? "s ".&shiftwidth : "t")." -"'
|
2015-05-23 08:25:29 -04:00
|
|
|
if !exists('g:formatters_json')
|
2015-05-31 14:58:14 -04:00
|
|
|
let g:formatters_json = [
|
|
|
|
\ 'jsbeautify_json',
|
|
|
|
\ 'pyjsbeautify_json',
|
|
|
|
\ ]
|
2015-05-23 08:25:29 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2015-06-13 11:53:44 -04:00
|
|
|
" HTML
|
|
|
|
let g:formatdef_htmlbeautify = '"html-beautify -f - -s ".&shiftwidth'
|
|
|
|
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'
|
|
|
|
if !exists('g:formatters_html')
|
|
|
|
let g:formatters_html = ['htmlbeautify', 'tidy_html']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" 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'
|
|
|
|
if !exists('g:formatters_xml')
|
|
|
|
let g:formatters_xml = ['tidy_xml']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" 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'
|
|
|
|
if !exists('g:formatters_xhtml')
|
|
|
|
let g:formatters_xhtml = ['tidy_xhtml']
|
|
|
|
endif
|
|
|
|
|
2015-05-23 08:25:29 -04:00
|
|
|
" Ruby
|
2015-06-09 04:18:22 -04:00
|
|
|
let g:formatdef_rbeautify = '"rbeautify ".(&expandtab ? "-s -c ".&shiftwidth : "-t")'
|
2015-05-23 08:25:29 -04:00
|
|
|
if !exists('g:formatters_ruby')
|
|
|
|
let g:formatters_ruby = ['rbeautify']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" CSS
|
|
|
|
let g:formatdef_cssbeautify = '"css-beautify -f - -s ".&shiftwidth'
|
|
|
|
if !exists('g:formatters_css')
|
|
|
|
let g:formatters_css = ['cssbeautify']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" SCSS
|
|
|
|
let g:formatdef_sassconvert = '"sass-convert -F scss -T scss --indent " . (&expandtab ? &shiftwidth : "t")'
|
|
|
|
if !exists('g:formatters_scss')
|
|
|
|
let g:formatters_scss = ['sassconvert']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
" Typescript
|
|
|
|
let g:formatdef_tsfmt = '"tsfmt --stdin %"'
|
|
|
|
if !exists('g:formatters_typescript')
|
|
|
|
let g:formatters_typescript = ['tsfmt']
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2015-06-13 05:10:25 -04:00
|
|
|
" Golang
|
2015-08-01 00:35:59 -04:00
|
|
|
" Two definitions are provided for two versions of gofmt.
|
|
|
|
" See issue #59
|
2015-06-13 10:30:13 -04:00
|
|
|
let g:formatdef_gofmt_1 = '"gofmt -tabs=".(&expandtab ? "false" : "true")." -tabwidth=".&shiftwidth'
|
|
|
|
let g:formatdef_gofmt_2 = '"gofmt"'
|
2015-06-13 05:10:25 -04:00
|
|
|
if !exists('g:formatters_go')
|
2015-06-13 10:30:13 -04:00
|
|
|
let g:formatters_go = ['gofmt_1', 'gofmt_2']
|
2015-06-13 05:10:25 -04:00
|
|
|
endif
|
|
|
|
|