diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/astyle.vim | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/autoload/ale/fixers/astyle.vim b/autoload/ale/fixers/astyle.vim index 9a837396..aea5cc8a 100644 --- a/autoload/ale/fixers/astyle.vim +++ b/autoload/ale/fixers/astyle.vim @@ -1,14 +1,27 @@ " Author: James Kim <jhlink@users.noreply.github.com> -" Description: Fix C files with astyle. +" Description: Fix C/C++ files with astyle. -call ale#Set('c_astyle_executable', 'astyle') +function! s:set_variables() abort + for l:ft in ['c', 'cpp'] + call ale#Set(l:ft . '_astyle_executable', 'astyle') + endfor +endfunction + +call s:set_variables() + +function! ale#fixers#astyle#Var(buffer, name) abort + let l:ft = getbufvar(str2nr(a:buffer), '&filetype') + let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c' + + return ale#Var(a:buffer, l:ft . '_astyle_' . a:name) +endfunction function! ale#fixers#astyle#Fix(buffer) abort - let l:executable = ale#Var(a:buffer, 'c_astyle_executable') + let l:executable = ale#fixers#astyle#Var(a:buffer, 'executable') + let l:command = ' %t' return { - \ 'command': ale#Escape(l:executable) - \ . ' %t', + \ 'command': ale#Escape(l:executable) . l:command, \ 'read_temporary_file': 1, \} endfunction |