From 3573975934f12588e431d902bb477429f635c747 Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 2 May 2017 22:44:08 +0100 Subject: Fix #410 - Use compile_commands.json files for clang-tidy, and check files on disk instead --- ale_linters/cpp/clangtidy.vim | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'ale_linters') diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim index 2acd345a..f538d14a 100644 --- a/ale_linters/cpp/clangtidy.vim +++ b/ale_linters/cpp/clangtidy.vim @@ -1,12 +1,24 @@ " Author: vdeurzen , w0rp " Description: clang-tidy linter for cpp files -" Set this option to change the clang-tidy options for warnings for C. -let g:ale_cpp_clangtidy_options = -\ get(g:, 'ale_cpp_clangtidy_options', '-std=c++14 -Wall') +" Set this option to check the checks clang-tidy will apply. +let g:ale_cpp_clangtidy_checks = get(g:, 'ale_cpp_clangtidy_checks', ['*']) + +" Set this option to manually set some options for clang-tidy. +" This will disable compile_commands.json detection. +let g:ale_cpp_clangtidy_options = get(g:, 'ale_cpp_clangtidy_options', '') function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort - return 'clang-tidy %t -- ' . ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:check_list = ale#Var(a:buffer, 'cpp_clangtidy_checks') + let l:check_option = !empty(l:check_list) + \ ? '-checks=' . shellescape(join(l:check_list, ',')) . ' ' + \ : '' + let l:user_options = ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:extra_options = !empty(l:user_options) + \ ? ' -- ' . l:user_options + \ : '' + + return 'clang-tidy ' . l:check_option . '%s' . l:extra_options endfunction call ale#linter#Define('cpp', { @@ -15,4 +27,5 @@ call ale#linter#Define('cpp', { \ 'executable': 'clang-tidy', \ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, \}) -- cgit v1.2.3