Merge pull request #2566 from grimmn/extend-clangtidy-options

Add additional options setting for clang-tidy linter
This commit is contained in:
w0rp 2019-06-08 22:45:39 +01:00 committed by GitHub
commit 6eb68b4507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 4 deletions

View File

@ -11,9 +11,12 @@ call ale#Set('c_clangtidy_executable', 'clang-tidy')
" http://clang.llvm.org/extra/clang-tidy/checks/list.html
call ale#Set('c_clangtidy_checks', [])
" Set this option to manually set some options for clang-tidy.
" Set this option to manually set some options for clang-tidy to use as compile
" flags.
" This will disable compile_commands.json detection.
call ale#Set('c_clangtidy_options', '')
" Set this option to manually set options for clang-tidy directly.
call ale#Set('c_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#c#clangtidy#GetCommand(buffer) abort
@ -25,8 +28,12 @@ function! ale_linters#c#clangtidy#GetCommand(buffer) abort
\ ? ale#Var(a:buffer, 'c_clangtidy_options')
\ : ''
" Get the options to pass directly to clang-tidy
let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options')
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '')

View File

@ -5,9 +5,12 @@
call ale#Set('cpp_clangtidy_executable', 'clang-tidy')
" Set this option to check the checks clang-tidy will apply.
call ale#Set('cpp_clangtidy_checks', [])
" Set this option to manually set some options for clang-tidy.
" Set this option to manually set some options for clang-tidy to use as compile
" flags.
" This will disable compile_commands.json detection.
call ale#Set('cpp_clangtidy_options', '')
" Set this option to manually set options for clang-tidy directly.
call ale#Set('cpp_clangtidy_extra_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
@ -19,8 +22,12 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
\ ? ale#Var(a:buffer, 'cpp_clangtidy_options')
\ : ''
" Get the options to pass directly to clang-tidy
let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options')
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '')

View File

@ -156,7 +156,7 @@ g:ale_c_clangtidy_options *g:ale_c_clangtidy_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
This variable can be changed to modify compiler flags given to clang-tidy.
- Setting this variable to a non-empty string,
- and working in a buffer where no compilation database is found using
@ -169,6 +169,14 @@ g:ale_c_clangtidy_options *g:ale_c_clangtidy_options*
of the |g:ale_c_build_dir_names| directories of the project tree.
g:ale_c_clangtidy_extra_options *g:ale_c_clangtidy_extra_options*
*b:ale_c_clangtidy_extra_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
===============================================================================
cppcheck *ale-c-cppcheck*

View File

@ -125,7 +125,7 @@ g:ale_cpp_clangtidy_options *g:ale_cpp_clangtidy_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
This variable can be changed to modify compiler flags given to clang-tidy.
- Setting this variable to a non-empty string,
- and working in a buffer where no compilation database is found using
@ -138,6 +138,14 @@ g:ale_cpp_clangtidy_options *g:ale_cpp_clangtidy_options*
of the |g:ale_c_build_dir_names| directories of the project tree.
g:ale_cpp_clangtidy_extra_options *g:ale_cpp_clangtidy_extra_options*
*b:ale_cpp_clangtidy_extra_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to clang-tidy.
===============================================================================
clazy *ale-cpp-clazy*

View File

@ -29,6 +29,12 @@ Execute(You should be able to manually set compiler flags for clang-tidy):
AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
Execute(You should be able to manually set flags for clang-tidy):
let b:ale_c_clangtidy_extra_options = '-config='
AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') . ' ' . ale#Escape('-config=') . ' %s'
Execute(The build directory should be configurable):
let b:ale_c_clangtidy_checks = ['*']
let b:ale_c_build_dir = '/foo/bar'

View File

@ -29,6 +29,12 @@ Execute(You should be able to manually set compiler flags for clang-tidy):
AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
Execute(You should be able to manually set flags for clang-tidy):
let b:ale_cpp_clangtidy_extra_options = '-config='
AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy') . ' ' . ale#Escape('-config=') . ' %s'
Execute(The build directory should be configurable):
let b:ale_cpp_clangtidy_checks = ['*']
let b:ale_c_build_dir = '/foo/bar'