All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 " Author: Peter Renström <renstrom.peter@gmail.com>
3 " Description: Fixing C/C++ files with clang-format.
5 call ale#Set('c_clangformat_executable', 'clang-format')
6 call ale#Set('c_clangformat_use_global', get(g:, 'ale_use_global_executables', 0))
7 call ale#Set('c_clangformat_options', '')
8 call ale#Set('c_clangformat_style_option', '')
9 call ale#Set('c_clangformat_use_local_file', 0)
11 function! ale#fixers#clangformat#GetExecutable(buffer) abort
12 return ale#path#FindExecutable(a:buffer, 'c_clangformat', [
17 function! ale#fixers#clangformat#Fix(buffer) abort
18 let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer))
19 let l:filename = ale#Escape(bufname(a:buffer))
20 let l:options = ale#Var(a:buffer, 'c_clangformat_options')
21 let l:style_option = ale#Var(a:buffer, 'c_clangformat_style_option')
22 let l:use_local_file = ale#Var(a:buffer, 'c_clangformat_use_local_file')
24 if l:style_option isnot# ''
25 let l:style_option = '-style=' . "'" . l:style_option . "'"
29 let l:config = ale#path#FindNearestFile(a:buffer, '.clang-format')
32 let l:style_option = '-style=file'
36 if l:style_option isnot# ''
37 let l:options .= ' ' . l:style_option
40 let l:command = l:executable . ' --assume-filename=' . l:filename
42 if l:options isnot# ''
43 let l:command .= ' ' . l:options
46 return {'command': l:command}