mirror of https://github.com/dense-analysis/ale
feat: Add cpp support to astyle fixer
This commit is contained in:
parent
d0b7a6e71f
commit
076f9efbd9
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue