mirror of
https://github.com/dense-analysis/ale.git
synced 2026-08-15 12:21:00 +08:00
feat: Add cpp support to astyle fixer
This commit is contained in:
@@ -1,14 +1,27 @@
|
|||||||
" Author: James Kim <jhlink@users.noreply.github.com>
|
" 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
|
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 {
|
return {
|
||||||
\ 'command': ale#Escape(l:executable)
|
\ 'command': ale#Escape(l:executable) . l:command,
|
||||||
\ . ' %t',
|
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user