From 4eba53eb3f7d376a08abb51fa55fde74e1818e5a Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sun, 21 Feb 2016 13:34:57 -0500 Subject: [PATCH] updated astyle to use .astylerc if available --- plugin/defaults.vim | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/plugin/defaults.vim b/plugin/defaults.vim index 9d70683..00157b9 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -25,7 +25,13 @@ endif " C# if !exists('g:formatdef_astyle_cs') - let g:formatdef_astyle_cs = '"astyle --mode=cs --style=ansi --indent-namespaces -pcH".(&expandtab ? "s".shiftwidth() : "t")' + if filereadable('.astylerc') + let g:formatdef_astyle_cs = '"astyle --mode=cs --options=.astyle"' + elseif filereadable(expand('~/.astylerc')) || exists('$ARTISTIC_STYLE_OPTIONS') + let g:formatdef_astyle_cs = '"astyle --mode=cs"' + else + let g:formatdef_astyle_cs = '"astyle --mode=cs --style=ansi --indent-namespaces -pcH".(&expandtab ? "s".shiftwidth() : "t")' + endif endif if !exists('g:formatters_cs') @@ -48,7 +54,13 @@ endfunction " C if !exists('g:formatdef_astyle_c') - let g:formatdef_astyle_c = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")' + if filereadable('.astylerc') + let g:formatdef_astyle_c = '"astyle --mode=c --options=.astyle"' + elseif filereadable(expand('~/.astylerc')) || exists('$ARTISTIC_STYLE_OPTIONS') + let g:formatdef_astyle_c = '"astyle --mode=c"' + else + let g:formatdef_astyle_c = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")' + endif endif if !exists('g:formatters_c') @@ -58,7 +70,13 @@ endif " C++ if !exists('g:formatdef_astyle_cpp') - let g:formatdef_astyle_cpp = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")' + if filereadable('.astylerc') + let g:formatdef_astyle_cpp = '"astyle --mode=c --options=.astyle"' + elseif filereadable(expand('~/.astylerc')) || exists('$ARTISTIC_STYLE_OPTIONS') + let g:formatdef_astyle_cpp = '"astyle --mode=c"' + else + let g:formatdef_astyle_cpp = '"astyle --mode=c --style=ansi -pcH".(&expandtab ? "s".shiftwidth() : "t")' + endif endif if !exists('g:formatters_cpp') @@ -74,7 +92,13 @@ endif " Java if !exists('g:formatdef_astyle_java') - let g:formatdef_astyle_java = '"astyle --mode=java --style=java -pcH".(&expandtab ? "s".shiftwidth() : "t")' + if filereadable('.astylerc') + let g:formatdef_astyle_java = '"astyle --mode=java --options=.astyle"' + elseif filereadable(expand('~/.astylerc')) || exists('$ARTISTIC_STYLE_OPTIONS') + let g:formatdef_astyle_java = '"astyle --mode=java"' + else + let g:formatdef_astyle_java = '"astyle --mode=java --style=java -pcH".(&expandtab ? "s".shiftwidth() : "t")' + endif endif if !exists('g:formatters_java')