diff options
-rw-r--r-- | ale_linters/cpp/clang.vim | 11 | ||||
-rw-r--r-- | ale_linters/cpp/gcc.vim | 11 | ||||
-rw-r--r-- | doc/ale-c.txt | 13 | ||||
-rw-r--r-- | doc/ale-cpp.txt | 7 | ||||
-rw-r--r-- | test/command_callback/test_cpp_clang_command_callbacks.vader | 4 | ||||
-rw-r--r-- | test/command_callback/test_cpp_gcc_command_callbacks.vader | 4 | ||||
-rw-r--r-- | test/test_c_import_paths.vader | 18 |
7 files changed, 44 insertions, 24 deletions
diff --git a/ale_linters/cpp/clang.vim b/ale_linters/cpp/clang.vim index 105df821..e8d96187 100644 --- a/ale_linters/cpp/clang.vim +++ b/ale_linters/cpp/clang.vim @@ -8,15 +8,15 @@ function! ale_linters#cpp#clang#GetExecutable(buffer) abort return ale#Var(a:buffer, 'cpp_clang_executable') endfunction -function! ale_linters#cpp#clang#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +function! ale_linters#cpp#clang#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer)) \ . ' -S -x c++ -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags \ . ale#Var(a:buffer, 'cpp_clang_options') . ' -' endfunction @@ -24,6 +24,9 @@ call ale#linter#Define('cpp', { \ 'name': 'clang', \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable', -\ 'command_callback': 'ale_linters#cpp#clang#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, +\ {'callback': 'ale_linters#cpp#clang#GetCommand'}, +\ ], \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim index 40dffc98..577c9f79 100644 --- a/ale_linters/cpp/gcc.vim +++ b/ale_linters/cpp/gcc.vim @@ -8,15 +8,15 @@ function! ale_linters#cpp#gcc#GetExecutable(buffer) abort return ale#Var(a:buffer, 'cpp_gcc_executable') endfunction -function! ale_linters#cpp#gcc#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer)) \ . ' -S -x c++ -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags \ . ale#Var(a:buffer, 'cpp_gcc_options') . ' -' endfunction @@ -24,6 +24,9 @@ call ale#linter#Define('cpp', { \ 'name': 'g++', \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable', -\ 'command_callback': 'ale_linters#cpp#gcc#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, +\ {'callback': 'ale_linters#cpp#gcc#GetCommand'}, +\ ], \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/doc/ale-c.txt b/doc/ale-c.txt index 08b83e80..c41f3bc8 100644 --- a/doc/ale-c.txt +++ b/doc/ale-c.txt @@ -31,7 +31,18 @@ g:ale_c_build_dir *g:ale_c_build_dir* database (it can be useful if multiple builds are in multiple build subdirectories in the project tree). This feature is also most useful for the clang tools linters, wrapped - aroung LibTooling (namely clang-tidy here) + around LibTooling (namely clang-tidy here) + + +g:ale_c_parse_makefile *g:ale_c_parse_makefile* + *b:ale_c_parse_makefile* + Type: |Number| + Default: `0` + + If set to `1`, ALE will run `make -n` to automatically determine flags to + set for C or C++ compilers. This can make it easier to determine the correct + build flags to use for different files. + =============================================================================== clang *ale-c-clang* diff --git a/doc/ale-cpp.txt b/doc/ale-cpp.txt index 315f293f..05e54799 100644 --- a/doc/ale-cpp.txt +++ b/doc/ale-cpp.txt @@ -5,8 +5,11 @@ ALE C++ Integration *ale-cpp-options* =============================================================================== Global Options -The |g:ale_c_build_dir_names| and |g:ale_c_build_dir| also apply to some C++ -linters too. +The following C options also apply to some C++ linters too. + +* |g:ale_c_build_dir_names| +* |g:ale_c_build_dir| +* |g:ale_c_parse_makefile| =============================================================================== diff --git a/test/command_callback/test_cpp_clang_command_callbacks.vader b/test/command_callback/test_cpp_clang_command_callbacks.vader index 67d6898c..8c671115 100644 --- a/test/command_callback/test_cpp_clang_command_callbacks.vader +++ b/test/command_callback/test_cpp_clang_command_callbacks.vader @@ -30,10 +30,10 @@ Execute(The executable should be configurable): Execute(The executable should be used in the command): AssertEqual \ ale#Escape('clang++') . b:command_tail, - \ ale_linters#cpp#clang#GetCommand(bufnr('')) + \ ale_linters#cpp#clang#GetCommand(bufnr(''), []) let b:ale_cpp_clang_executable = 'foobar' AssertEqual \ ale#Escape('foobar') . b:command_tail, - \ ale_linters#cpp#clang#GetCommand(bufnr('')) + \ ale_linters#cpp#clang#GetCommand(bufnr(''), []) diff --git a/test/command_callback/test_cpp_gcc_command_callbacks.vader b/test/command_callback/test_cpp_gcc_command_callbacks.vader index 9ab4d5cb..7abebf4c 100644 --- a/test/command_callback/test_cpp_gcc_command_callbacks.vader +++ b/test/command_callback/test_cpp_gcc_command_callbacks.vader @@ -30,10 +30,10 @@ Execute(The executable should be configurable): Execute(The executable should be used in the command): AssertEqual \ ale#Escape('gcc') . b:command_tail, - \ ale_linters#cpp#gcc#GetCommand(bufnr('')) + \ ale_linters#cpp#gcc#GetCommand(bufnr(''), []) let b:ale_cpp_gcc_executable = 'foobar' AssertEqual \ ale#Escape('foobar') . b:command_tail, - \ ale_linters#cpp#gcc#GetCommand(bufnr('')) + \ ale_linters#cpp#gcc#GetCommand(bufnr(''), []) diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader index a2ffe54e..f2a06781 100644 --- a/test/test_c_import_paths.vader +++ b/test/test_c_import_paths.vader @@ -146,7 +146,7 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' ' \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr('')) + \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) Execute(The C++ GCC handler should include 'include' directories for projects with a configure file): runtime! ale_linters/cpp/gcc.vim @@ -159,7 +159,7 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' ' \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr('')) + \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) Execute(The C++ GCC handler should include root directories for projects with .h files in them): runtime! ale_linters/cpp/gcc.vim @@ -172,7 +172,7 @@ Execute(The C++ GCC handler should include root directories for projects with .h \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr('')) + \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) Execute(The C++ GCC handler should include root directories for projects with .hpp files in them): runtime! ale_linters/cpp/gcc.vim @@ -185,7 +185,7 @@ Execute(The C++ GCC handler should include root directories for projects with .h \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' ' \ . ' -' - \ , ale_linters#cpp#gcc#GetCommand(bufnr('')) + \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), []) Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile): runtime! ale_linters/cpp/clang.vim @@ -198,7 +198,7 @@ Execute(The C++ Clang handler should include 'include' directories for projects \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' ' \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr('')) + \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) Execute(The C++ Clang handler should include 'include' directories for projects with a configure file): runtime! ale_linters/cpp/clang.vim @@ -211,7 +211,7 @@ Execute(The C++ Clang handler should include 'include' directories for projects \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' ' \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr('')) + \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) Execute(The C++ Clang handler should include root directories for projects with .h files in them): runtime! ale_linters/cpp/clang.vim @@ -224,7 +224,7 @@ Execute(The C++ Clang handler should include root directories for projects with \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' ' \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr('')) + \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) Execute(The C++ Clang handler should include root directories for projects with .hpp files in them): runtime! ale_linters/cpp/clang.vim @@ -237,7 +237,7 @@ Execute(The C++ Clang handler should include root directories for projects with \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' ' \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr('')) + \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) Execute(The C++ Clang handler shoud use the include directory based on the .git location): runtime! ale_linters/cpp/clang.vim @@ -258,7 +258,7 @@ Execute(The C++ Clang handler shoud use the include directory based on the .git \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' ' \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/git_and_nested_makefiles/include')) . ' ' \ . ' -' - \ , ale_linters#cpp#clang#GetCommand(bufnr('')) + \ , ale_linters#cpp#clang#GetCommand(bufnr(''), []) Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them): runtime! ale_linters/cpp/clangtidy.vim |