mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 21:44:47 +08:00
Merge pull request #2646 from paulreimer/fixer-clangformat-use-assume-filename
Set --assume-filename for clangformat fixer
This commit is contained in:
@@ -13,10 +13,15 @@ function! ale#fixers#clangformat#GetExecutable(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#fixers#clangformat#Fix(buffer) abort
|
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')
|
let l:options = ale#Var(a:buffer, 'c_clangformat_options')
|
||||||
|
|
||||||
return {
|
let l:command = l:executable . ' --assume-filename=' . l:filename
|
||||||
\ 'command': ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer))
|
|
||||||
\ . ' ' . l:options,
|
if l:options isnot# ''
|
||||||
\}
|
let l:command .= ' ' . l:options
|
||||||
|
endif
|
||||||
|
|
||||||
|
return {'command': l:command}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Execute(The clang-format callback should return the correct default values):
|
|||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
|
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
|
||||||
\ . ' '
|
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#clangformat#Fix(bufnr(''))
|
\ ale#fixers#clangformat#Fix(bufnr(''))
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ Execute(The clangformat callback should include any additional options):
|
|||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
|
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
|
||||||
|
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
|
||||||
\ . ' --some-option',
|
\ . ' --some-option',
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#clangformat#Fix(bufnr(''))
|
\ ale#fixers#clangformat#Fix(bufnr(''))
|
||||||
|
|||||||
Reference in New Issue
Block a user