summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Vander Mey <jvandermey@evertz.com>2019-06-08 15:12:43 -0400
committerJonathan Vander Mey <jvandermey@evertz.com>2019-06-08 15:35:08 -0400
commit3c799abb44a4cc9a7b6c5bfcf583862946e57240 (patch)
treef3cb9d909f72712ab83eaa08fd48a557fa9cb541
parent7b78f2b846e2f3443dcb2ceacee54eb99e37f040 (diff)
downloadale-3c799abb44a4cc9a7b6c5bfcf583862946e57240.zip
Add additional option setting for clangtidy linter
The existing option setting handles setting additional compile flags to pass to clang-tidy. The new option setting added here allows setting additional clang-tidy specific flags to be passed as well. Fixes #2324
-rw-r--r--ale_linters/c/clangtidy.vim9
-rw-r--r--ale_linters/cpp/clangtidy.vim9
-rw-r--r--doc/ale-c.txt10
-rw-r--r--doc/ale-cpp.txt10
-rw-r--r--test/command_callback/test_c_clang_tidy_command_callback.vader6
-rw-r--r--test/command_callback/test_clang_tidy_command_callback.vader6
6 files changed, 46 insertions, 4 deletions
diff --git a/ale_linters/c/clangtidy.vim b/ale_linters/c/clangtidy.vim
index 6484f8af..f998866a 100644
--- a/ale_linters/c/clangtidy.vim
+++ b/ale_linters/c/clangtidy.vim
@@ -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 : '')
diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim
index 841b795f..085bc332 100644
--- a/ale_linters/cpp/clangtidy.vim
+++ b/ale_linters/cpp/clangtidy.vim
@@ -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 : '')
diff --git a/doc/ale-c.txt b/doc/ale-c.txt
index be0a3d77..ec7304f4 100644
--- a/doc/ale-c.txt
+++ b/doc/ale-c.txt
@@ -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*
diff --git a/doc/ale-cpp.txt b/doc/ale-cpp.txt
index e1f64ab5..50855c10 100644
--- a/doc/ale-cpp.txt
+++ b/doc/ale-cpp.txt
@@ -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*
diff --git a/test/command_callback/test_c_clang_tidy_command_callback.vader b/test/command_callback/test_c_clang_tidy_command_callback.vader
index f78d0ea7..fa76c66c 100644
--- a/test/command_callback/test_c_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_c_clang_tidy_command_callback.vader
@@ -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'
diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader
index 3297a4cb..53ae311b 100644
--- a/test/command_callback/test_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_clang_tidy_command_callback.vader
@@ -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'