diff options
author | w0rp <w0rp@users.noreply.github.com> | 2019-07-30 08:21:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-30 08:21:21 +0100 |
commit | 8f5ecf01200f82d12d452992a92c23fcf9e0f0e8 (patch) | |
tree | da780f21863dbea58b818dbceb514893954ce1ca | |
parent | d1c56769b750a14a51c16cc7973ab0af15aa0cbf (diff) | |
parent | d25711a51686d45a2406c81163c144aeffda7033 (diff) | |
download | ale-8f5ecf01200f82d12d452992a92c23fcf9e0f0e8.zip |
Merge pull request #2646 from paulreimer/fixer-clangformat-use-assume-filename
Set --assume-filename for clangformat fixer
-rw-r--r-- | autoload/ale/fixers/clangformat.vim | 13 | ||||
-rw-r--r-- | test/fixers/test_clangformat_fixer_callback.vader | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/autoload/ale/fixers/clangformat.vim b/autoload/ale/fixers/clangformat.vim index eae1a7b4..ea5743a5 100644 --- a/autoload/ale/fixers/clangformat.vim +++ b/autoload/ale/fixers/clangformat.vim @@ -13,10 +13,15 @@ function! ale#fixers#clangformat#GetExecutable(buffer) abort endfunction function! ale#fixers#clangformat#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer)) + let l:filename = ale#Escape(bufname(a:buffer)) let l:options = ale#Var(a:buffer, 'c_clangformat_options') - return { - \ 'command': ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer)) - \ . ' ' . l:options, - \} + let l:command = l:executable . ' --assume-filename=' . l:filename + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return {'command': l:command} endfunction diff --git a/test/fixers/test_clangformat_fixer_callback.vader b/test/fixers/test_clangformat_fixer_callback.vader index a55576bf..ae7db4cf 100644 --- a/test/fixers/test_clangformat_fixer_callback.vader +++ b/test/fixers/test_clangformat_fixer_callback.vader @@ -20,7 +20,7 @@ Execute(The clang-format callback should return the correct default values): AssertEqual \ { \ 'command': ale#Escape(g:ale_c_clangformat_executable) - \ . ' ' + \ . ' --assume-filename=' . ale#Escape(bufname(bufnr(''))) \ }, \ ale#fixers#clangformat#Fix(bufnr('')) @@ -31,6 +31,7 @@ Execute(The clangformat callback should include any additional options): AssertEqual \ { \ 'command': ale#Escape(g:ale_c_clangformat_executable) + \ . ' --assume-filename=' . ale#Escape(bufname(bufnr(''))) \ . ' --some-option', \ }, \ ale#fixers#clangformat#Fix(bufnr('')) |