mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-10 14:31:52 +08:00
#2919 Use compile_commands.json for headers
This commit is contained in:
@@ -9,13 +9,6 @@ let s:sep = has('win32') ? '\' : '/'
|
|||||||
let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt']
|
let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt']
|
||||||
|
|
||||||
function! ale#c#GetBuildDirectory(buffer) abort
|
function! ale#c#GetBuildDirectory(buffer) abort
|
||||||
" Don't include build directory for header files, as compile_commands.json
|
|
||||||
" files don't consider headers to be translation units, and provide no
|
|
||||||
" commands for compiling header files.
|
|
||||||
if expand('#' . a:buffer) =~# '\v\.(h|hpp)$'
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
|
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
|
||||||
|
|
||||||
" c_build_dir has the priority if defined
|
" c_build_dir has the priority if defined
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ Execute(The build directory setting should override the options):
|
|||||||
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
||||||
\ . ' -p ' . ale#Escape('/foo/bar')
|
\ . ' -p ' . ale#Escape('/foo/bar')
|
||||||
|
|
||||||
Execute(The build directory should be ignored for header files):
|
Execute(The build directory should be used for header files):
|
||||||
call ale#test#SetFilename('test.h')
|
call ale#test#SetFilename('test.h')
|
||||||
|
|
||||||
let b:ale_c_clangtidy_checks = ['*']
|
let b:ale_c_clangtidy_checks = ['*']
|
||||||
@@ -66,12 +66,8 @@ Execute(The build directory should be ignored for header files):
|
|||||||
|
|
||||||
AssertLinter 'clang-tidy',
|
AssertLinter 'clang-tidy',
|
||||||
\ ale#Escape('clang-tidy')
|
\ ale#Escape('clang-tidy')
|
||||||
\ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
|
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
||||||
|
\ . ' -p ' . ale#Escape('/foo/bar')
|
||||||
call ale#test#SetFilename('test.h')
|
|
||||||
|
|
||||||
AssertLinter 'clang-tidy',
|
|
||||||
\ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
|
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
let b:ale_c_clangtidy_checks = ['*']
|
let b:ale_c_clangtidy_checks = ['*']
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ Execute(The build directory setting should override the options):
|
|||||||
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
||||||
\ . ' -p ' . ale#Escape('/foo/bar')
|
\ . ' -p ' . ale#Escape('/foo/bar')
|
||||||
|
|
||||||
Execute(The build directory should be ignored for header files):
|
Execute(The build directory should be used for header files):
|
||||||
call ale#test#SetFilename('test.h')
|
call ale#test#SetFilename('test.h')
|
||||||
|
|
||||||
let b:ale_cpp_clangtidy_checks = ['*']
|
let b:ale_cpp_clangtidy_checks = ['*']
|
||||||
@@ -66,12 +66,15 @@ Execute(The build directory should be ignored for header files):
|
|||||||
|
|
||||||
AssertLinter 'clang-tidy',
|
AssertLinter 'clang-tidy',
|
||||||
\ ale#Escape('clang-tidy')
|
\ ale#Escape('clang-tidy')
|
||||||
\ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
|
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
||||||
|
\ . ' -p ' . ale#Escape('/foo/bar')
|
||||||
|
|
||||||
call ale#test#SetFilename('test.hpp')
|
call ale#test#SetFilename('test.hpp')
|
||||||
|
|
||||||
AssertLinter 'clang-tidy',
|
AssertLinter 'clang-tidy',
|
||||||
\ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
|
\ ale#Escape('clang-tidy')
|
||||||
|
\ . ' -checks=' . ale#Escape('*') . ' %s'
|
||||||
|
\ . ' -p ' . ale#Escape('/foo/bar')
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
let b:ale_cpp_clangtidy_checks = ['*']
|
let b:ale_cpp_clangtidy_checks = ['*']
|
||||||
|
|||||||
@@ -34,18 +34,20 @@ Execute(The build directory should be configurable):
|
|||||||
\ ale#Escape('clazy-standalone')
|
\ ale#Escape('clazy-standalone')
|
||||||
\ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
|
\ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
|
||||||
|
|
||||||
Execute(The build directory should be ignored for header files):
|
Execute(The build directory should be used for header files):
|
||||||
call ale#test#SetFilename('test.h')
|
call ale#test#SetFilename('test.h')
|
||||||
|
|
||||||
let b:ale_c_build_dir = '/foo/bar'
|
let b:ale_c_build_dir = '/foo/bar'
|
||||||
|
|
||||||
AssertLinter 'clazy-standalone',
|
AssertLinter 'clazy-standalone',
|
||||||
\ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s'
|
\ ale#Escape('clazy-standalone')
|
||||||
|
\ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
|
||||||
|
|
||||||
call ale#test#SetFilename('test.hpp')
|
call ale#test#SetFilename('test.hpp')
|
||||||
|
|
||||||
AssertLinter 'clazy-standalone',
|
AssertLinter 'clazy-standalone',
|
||||||
\ ale#Escape('clazy-standalone') . ' -checks=' . ale#Escape('level1') . ' %s'
|
\ ale#Escape('clazy-standalone')
|
||||||
|
\ . ' -checks=' . ale#Escape('level1') . ' -p ' . ale#Escape('/foo/bar') . ' %s'
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
let b:ale_cpp_clazy_executable = 'foobar'
|
let b:ale_cpp_clazy_executable = 'foobar'
|
||||||
|
|||||||
Reference in New Issue
Block a user