summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorjhlink <jhlink@users.noreply.github.com>2020-07-25 20:20:47 -0400
committerjhlink <jhlink@users.noreply.github.com>2020-07-25 20:20:47 -0400
commit076f9efbd951c91a36cb0b3c7421277746c1f3fd (patch)
tree9d32a3b01dc08e0825cbc50f94e0a3ad9559114e /autoload
parentd0b7a6e71fb6293c104ff3a56cabcb5cfde9f065 (diff)
downloadale-076f9efbd951c91a36cb0b3c7421277746c1f3fd.zip
feat: Add cpp support to astyle fixer
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fixers/astyle.vim23
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