Add clang-format fixer for C/C++ (#873)
* Add clang-format fixer for C/C++ * Document clang-format options * Refer ale-cpp-clangformat to ale-c-clangformat
This commit is contained in:
@@ -82,6 +82,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['php'],
|
||||
\ 'description': 'Fix PHP files with phpcbf.',
|
||||
\ },
|
||||
\ 'clang-format': {
|
||||
\ 'function': 'ale#fixers#clangformat#Fix',
|
||||
\ 'suggested_filetypes': ['c', 'cpp'],
|
||||
\ 'description': 'Fix C/C++ files with clang-format.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
||||
21
autoload/ale/fixers/clangformat.vim
Normal file
21
autoload/ale/fixers/clangformat.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
" Author: Peter Renström <renstrom.peter@gmail.com>
|
||||
" Description: Fixing C/C++ files with clang-format.
|
||||
|
||||
call ale#Set('c_clangformat_executable', 'clang-format')
|
||||
call ale#Set('c_clangformat_use_global', 0)
|
||||
call ale#Set('c_clangformat_options', '')
|
||||
|
||||
function! ale#fixers#clangformat#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'c_clangformat', [
|
||||
\ 'clang-format',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#clangformat#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'c_clangformat_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer))
|
||||
\ . ' ' . l:options,
|
||||
\}
|
||||
endfunction
|
||||
Reference in New Issue
Block a user