mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
#3299 Merge gcc and clang into a cc linter
Users can easily be confused when they set some options for a C or C++ compiler, and another compiler is run with different options, which still reports errors. To remedy this, the existing `gcc` and `clang` linters have been replaced with a `cc` linter that will run either compiler. This is a breaking change for ALE v3.0.0.
This commit is contained in:
@@ -1,12 +1,27 @@
|
|||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: gcc linter for c files
|
" Description: A C compiler linter for C files with gcc/clang, etc.
|
||||||
|
|
||||||
call ale#Set('c_gcc_executable', 'gcc')
|
call ale#Set('c_cc_executable', '<auto>')
|
||||||
call ale#Set('c_gcc_options', '-std=c11 -Wall')
|
call ale#Set('c_cc_options', '-std=c11 -Wall')
|
||||||
|
|
||||||
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
|
function! ale_linters#c#cc#GetExecutable(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'c_cc_executable')
|
||||||
|
|
||||||
|
" Default to either clang or gcc.
|
||||||
|
if l:executable is# '<auto>'
|
||||||
|
if ale#engine#IsExecutable(a:buffer, 'clang')
|
||||||
|
let l:executable = 'clang'
|
||||||
|
else
|
||||||
|
let l:executable = 'gcc'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:executable
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#c#cc#GetCommand(buffer, output) abort
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||||
let l:ale_flags = ale#Var(a:buffer, 'c_gcc_options')
|
let l:ale_flags = ale#Var(a:buffer, 'c_cc_options')
|
||||||
|
|
||||||
if l:cflags =~# '-std='
|
if l:cflags =~# '-std='
|
||||||
let l:ale_flags = substitute(
|
let l:ale_flags = substitute(
|
||||||
@@ -29,9 +44,10 @@ function! ale_linters#c#gcc#GetCommand(buffer, output) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
\ 'name': 'gcc',
|
\ 'name': 'cc',
|
||||||
|
\ 'aliases': ['gcc', 'clang'],
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': {b -> ale#Var(b, 'c_gcc_executable')},
|
\ 'executable': function('ale_linters#c#cc#GetExecutable'),
|
||||||
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#gcc#GetCommand'))},
|
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#cc#GetCommand'))},
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
|
||||||
\})
|
\})
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
" Author: Masahiro H https://github.com/mshr-h
|
|
||||||
" Description: clang linter for c files
|
|
||||||
|
|
||||||
call ale#Set('c_clang_executable', 'clang')
|
|
||||||
call ale#Set('c_clang_options', '-std=c11 -Wall')
|
|
||||||
|
|
||||||
function! ale_linters#c#clang#GetCommand(buffer, output) abort
|
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
|
||||||
let l:ale_flags = ale#Var(a:buffer, 'c_clang_options')
|
|
||||||
|
|
||||||
if l:cflags =~# '-std='
|
|
||||||
let l:ale_flags = substitute(
|
|
||||||
\ l:ale_flags,
|
|
||||||
\ '-std=\(c\|gnu\)[0-9]\{2\}',
|
|
||||||
\ '',
|
|
||||||
\ 'g')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
|
||||||
" headers in the same directory.
|
|
||||||
return '%e -S -x c -fsyntax-only'
|
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
|
||||||
\ . ale#Pad(l:cflags)
|
|
||||||
\ . ale#Pad(l:ale_flags) . ' -'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('c', {
|
|
||||||
\ 'name': 'clang',
|
|
||||||
\ 'output_stream': 'stderr',
|
|
||||||
\ 'executable': {b -> ale#Var(b, 'c_clang_executable')},
|
|
||||||
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clang#GetCommand'))},
|
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
|
|
||||||
\})
|
|
||||||
53
ale_linters/cpp/cc.vim
Normal file
53
ale_linters/cpp/cc.vim
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
|
" Description: A C++ compiler linter for C++ files with gcc/clang, etc.
|
||||||
|
|
||||||
|
call ale#Set('cpp_cc_executable', '<auto>')
|
||||||
|
call ale#Set('cpp_cc_options', '-std=c++14 -Wall')
|
||||||
|
|
||||||
|
function! ale_linters#cpp#cc#GetExecutable(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'cpp_cc_executable')
|
||||||
|
|
||||||
|
" Default to either clang++ or gcc.
|
||||||
|
if l:executable is# '<auto>'
|
||||||
|
if ale#engine#IsExecutable(a:buffer, 'clang++')
|
||||||
|
let l:executable = 'clang++'
|
||||||
|
else
|
||||||
|
let l:executable = 'gcc'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:executable
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#cpp#cc#GetCommand(buffer, output) abort
|
||||||
|
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||||
|
let l:ale_flags = ale#Var(a:buffer, 'cpp_cc_options')
|
||||||
|
|
||||||
|
if l:cflags =~# '-std='
|
||||||
|
let l:ale_flags = substitute(
|
||||||
|
\ l:ale_flags,
|
||||||
|
\ '-std=\(c\|gnu\)++[0-9]\{2\}',
|
||||||
|
\ '',
|
||||||
|
\ 'g')
|
||||||
|
endif
|
||||||
|
|
||||||
|
" -iquote with the directory the file is in makes #include work for
|
||||||
|
" headers in the same directory.
|
||||||
|
"
|
||||||
|
" `-o /dev/null` or `-o null` is needed to catch all errors,
|
||||||
|
" -fsyntax-only doesn't catch everything.
|
||||||
|
return '%e -S -x c++'
|
||||||
|
\ . ' -o ' . g:ale#util#nul_file
|
||||||
|
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||||
|
\ . ale#Pad(l:cflags)
|
||||||
|
\ . ale#Pad(l:ale_flags) . ' -'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('cpp', {
|
||||||
|
\ 'name': 'cc',
|
||||||
|
\ 'aliases': ['gcc', 'clang', 'g++', 'clang++'],
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable': function('ale_linters#cpp#cc#GetExecutable'),
|
||||||
|
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#cc#GetCommand'))},
|
||||||
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
|
||||||
|
\})
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
" Author: Tomota Nakamura <https://github.com/tomotanakamura>
|
|
||||||
" Description: clang linter for cpp files
|
|
||||||
|
|
||||||
call ale#Set('cpp_clang_executable', 'clang++')
|
|
||||||
call ale#Set('cpp_clang_options', '-std=c++14 -Wall')
|
|
||||||
|
|
||||||
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
|
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
|
||||||
let l:ale_flags = ale#Var(a:buffer, 'cpp_clang_options')
|
|
||||||
|
|
||||||
if l:cflags =~# '-std='
|
|
||||||
let l:ale_flags = substitute(
|
|
||||||
\ l:ale_flags,
|
|
||||||
\ '-std=\(c\|gnu\)++[0-9]\{2\}',
|
|
||||||
\ '',
|
|
||||||
\ 'g')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
|
||||||
" headers in the same directory.
|
|
||||||
return '%e -S -x c++ -fsyntax-only'
|
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
|
||||||
\ . ale#Pad(l:cflags)
|
|
||||||
\ . ale#Pad(l:ale_flags) . ' -'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
|
||||||
\ 'name': 'clang',
|
|
||||||
\ 'output_stream': 'stderr',
|
|
||||||
\ 'executable': {b -> ale#Var(b, 'cpp_clang_executable')},
|
|
||||||
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clang#GetCommand'))},
|
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
|
|
||||||
\})
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
" Author: geam <mdelage@student.42.fr>
|
|
||||||
" Description: gcc linter for cpp files
|
|
||||||
"
|
|
||||||
call ale#Set('cpp_gcc_executable', 'gcc')
|
|
||||||
call ale#Set('cpp_gcc_options', '-std=c++14 -Wall')
|
|
||||||
|
|
||||||
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
|
|
||||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
|
||||||
let l:ale_flags = ale#Var(a:buffer, 'cpp_gcc_options')
|
|
||||||
|
|
||||||
if l:cflags =~# '-std='
|
|
||||||
let l:ale_flags = substitute(
|
|
||||||
\ l:ale_flags,
|
|
||||||
\ '-std=\(c\|gnu\)++[0-9]\{2\}',
|
|
||||||
\ '',
|
|
||||||
\ 'g')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
|
||||||
" headers in the same directory.
|
|
||||||
"
|
|
||||||
" `-o /dev/null` or `-o null` is needed to catch all errors,
|
|
||||||
" -fsyntax-only doesn't catch everything.
|
|
||||||
return '%e -S -x c++'
|
|
||||||
\ . ' -o ' . g:ale#util#nul_file
|
|
||||||
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
|
||||||
\ . ale#Pad(l:cflags)
|
|
||||||
\ . ale#Pad(l:ale_flags) . ' -'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
|
||||||
\ 'name': 'gcc',
|
|
||||||
\ 'aliases': ['g++'],
|
|
||||||
\ 'output_stream': 'stderr',
|
|
||||||
\ 'executable': {b -> ale#Var(b, 'cpp_gcc_executable')},
|
|
||||||
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#gcc#GetCommand'))},
|
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
|
|
||||||
\})
|
|
||||||
117
doc/ale-c.txt
117
doc/ale-c.txt
@@ -1,6 +1,9 @@
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
ALE C Integration *ale-c-options*
|
ALE C Integration *ale-c-options*
|
||||||
|
|
||||||
|
For basic checking of problems with C files, ALE offers the `cc` linter, which
|
||||||
|
runs either `clang`, or `gcc`. See |ale-c-cc|.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
Global Options
|
Global Options
|
||||||
@@ -11,12 +14,12 @@ g:ale_c_build_dir_names *g:ale_c_build_dir_names*
|
|||||||
Type: |List|
|
Type: |List|
|
||||||
Default: `['build', 'bin']`
|
Default: `['build', 'bin']`
|
||||||
|
|
||||||
A list of directory names to be used when searching upwards from cpp
|
A list of directory names to be used when searching upwards from cpp files
|
||||||
files to discover compilation databases with. For directory named `'foo'`,
|
to discover compilation databases with. For directory named `'foo'`, ALE
|
||||||
ALE will search for `'foo/compile_commands.json'` in all directories on and above
|
will search for `'foo/compile_commands.json'` in all directories on and
|
||||||
the directory containing the cpp file to find path to compilation database.
|
above the directory containing the cpp file to find path to compilation
|
||||||
This feature is useful for the clang tools wrapped around LibTooling (namely
|
database. This feature is useful for the clang tools wrapped around
|
||||||
here, clang-tidy)
|
LibTooling (namely here, clang-tidy)
|
||||||
|
|
||||||
|
|
||||||
g:ale_c_build_dir *g:ale_c_build_dir*
|
g:ale_c_build_dir *g:ale_c_build_dir*
|
||||||
@@ -94,22 +97,58 @@ g:ale_c_astyle_project_options *g:ale_c_astyle_project_options*
|
|||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
clang *ale-c-clang*
|
cc *ale-c-cc*
|
||||||
|
*ale-c-gcc*
|
||||||
|
*ale-c-clang*
|
||||||
|
|
||||||
g:ale_c_clang_executable *g:ale_c_clang_executable*
|
g:ale_c_cc_executable *g:ale_c_cc_executable*
|
||||||
*b:ale_c_clang_executable*
|
*b:ale_c_cc_executable*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'clang'`
|
Default: `'<auto>'`
|
||||||
|
|
||||||
This variable can be changed to use a different executable for clang.
|
This variable can be changed to use a different executable for a C compiler.
|
||||||
|
|
||||||
|
ALE will try to use `clang` if Clang is available, otherwise ALE will
|
||||||
|
default to checking C code with `gcc`.
|
||||||
|
|
||||||
|
|
||||||
g:ale_c_clang_options *g:ale_c_clang_options*
|
g:ale_c_cc_options *g:ale_c_cc_options*
|
||||||
*b:ale_c_clang_options*
|
*b:ale_c_cc_options*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'-std=c11 -Wall'`
|
Default: `'-std=c11 -Wall'`
|
||||||
|
|
||||||
This variable can be changed to modify flags given to clang.
|
This variable can be change to modify flags given to the C compiler.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
ccls *ale-c-ccls*
|
||||||
|
|
||||||
|
g:ale_c_ccls_executable *g:ale_c_ccls_executable*
|
||||||
|
*b:ale_c_ccls_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'ccls'`
|
||||||
|
|
||||||
|
This variable can be changed to use a different executable for ccls.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_c_ccls_init_options *g:ale_c_ccls_init_options*
|
||||||
|
*b:ale_c_ccls_init_options*
|
||||||
|
Type: |Dictionary|
|
||||||
|
Default: `{}`
|
||||||
|
|
||||||
|
This variable can be changed to customize ccls initialization options.
|
||||||
|
Example: >
|
||||||
|
{
|
||||||
|
\ 'cacheDirectory': '/tmp/ccls',
|
||||||
|
\ 'cacheFormat': 'binary',
|
||||||
|
\ 'diagnostics': {
|
||||||
|
\ 'onOpen': 0,
|
||||||
|
\ 'opChange': 1000,
|
||||||
|
\ },
|
||||||
|
\ }
|
||||||
|
<
|
||||||
|
Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all
|
||||||
|
available options and explanations.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
@@ -294,25 +333,6 @@ g:ale_c_flawfinder_error_severity *g:ale_c_flawfinder_error_severity*
|
|||||||
error. This setting also applies to flawfinder for c++.
|
error. This setting also applies to flawfinder for c++.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
gcc *ale-c-gcc*
|
|
||||||
|
|
||||||
g:ale_c_gcc_executable *g:ale_c_gcc_executable*
|
|
||||||
*b:ale_c_gcc_executable*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'gcc'`
|
|
||||||
|
|
||||||
This variable can be changed to use a different executable for gcc.
|
|
||||||
|
|
||||||
|
|
||||||
g:ale_c_gcc_options *g:ale_c_gcc_options*
|
|
||||||
*b:ale_c_gcc_options*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'-std=c11 -Wall'`
|
|
||||||
|
|
||||||
This variable can be change to modify flags given to gcc.
|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
uncrustify *ale-c-uncrustify*
|
uncrustify *ale-c-uncrustify*
|
||||||
|
|
||||||
@@ -332,36 +352,5 @@ g:ale_c_uncrustify_options *g:ale_c_uncrustify_options*
|
|||||||
This variable can be change to modify flags given to uncrustify.
|
This variable can be change to modify flags given to uncrustify.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
ccls *ale-c-ccls*
|
|
||||||
|
|
||||||
g:ale_c_ccls_executable *g:ale_c_ccls_executable*
|
|
||||||
*b:ale_c_ccls_executable*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'ccls'`
|
|
||||||
|
|
||||||
This variable can be changed to use a different executable for ccls.
|
|
||||||
|
|
||||||
|
|
||||||
g:ale_c_ccls_init_options *g:ale_c_ccls_init_options*
|
|
||||||
*b:ale_c_ccls_init_options*
|
|
||||||
Type: |Dictionary|
|
|
||||||
Default: `{}`
|
|
||||||
|
|
||||||
This variable can be changed to customize ccls initialization options.
|
|
||||||
Example: >
|
|
||||||
{
|
|
||||||
\ 'cacheDirectory': '/tmp/ccls',
|
|
||||||
\ 'cacheFormat': 'binary',
|
|
||||||
\ 'diagnostics': {
|
|
||||||
\ 'onOpen': 0,
|
|
||||||
\ 'opChange': 1000,
|
|
||||||
\ },
|
|
||||||
\ }
|
|
||||||
<
|
|
||||||
Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all
|
|
||||||
available options and explanations.
|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|||||||
125
doc/ale-cpp.txt
125
doc/ale-cpp.txt
@@ -1,6 +1,9 @@
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
ALE C++ Integration *ale-cpp-options*
|
ALE C++ Integration *ale-cpp-options*
|
||||||
|
|
||||||
|
For basic checking of problems with C++ files, ALE offers the `cc` linter,
|
||||||
|
which runs either `clang++`, or `gcc`. See |ale-cpp-cc|.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
Global Options
|
Global Options
|
||||||
@@ -38,41 +41,58 @@ g:ale_cpp_astyle_project_options *g:ale_cpp_astyle_project_options*
|
|||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
clang *ale-cpp-clang*
|
cc *ale-cpp-cc*
|
||||||
|
*ale-cpp-gcc*
|
||||||
|
*ale-cpp-clang*
|
||||||
|
|
||||||
g:ale_cpp_clang_executable *g:ale_cpp_clang_executable*
|
g:ale_cpp_cc_executable *g:ale_cpp_cc_executable*
|
||||||
*b:ale_cpp_clang_executable*
|
*b:ale_cpp_cc_executable*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'clang++'`
|
Default: `'<auto>'`
|
||||||
|
|
||||||
This variable can be changed to use a different executable for clang.
|
This variable can be changed to use a different executable for a C++ compiler.
|
||||||
|
|
||||||
|
ALE will try to use `clang++` if Clang is available, otherwise ALE will
|
||||||
|
default to checking C++ code with `gcc`.
|
||||||
|
|
||||||
|
|
||||||
g:ale_cpp_clang_options *g:ale_cpp_clang_options*
|
g:ale_cpp_cc_options *g:ale_cpp_cc_options*
|
||||||
*b:ale_cpp_clang_options*
|
*b:ale_cpp_cc_options*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'-std=c++14 -Wall'`
|
Default: `'-std=c++14 -Wall'`
|
||||||
|
|
||||||
This variable can be changed to modify flags given to clang.
|
This variable can be change to modify flags given to the C++ compiler.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
clangd *ale-cpp-clangd*
|
ccls *ale-cpp-ccls*
|
||||||
|
|
||||||
g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable*
|
g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable*
|
||||||
*b:ale_cpp_clangd_executable*
|
*b:ale_cpp_ccls_executable*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'clangd'`
|
Default: `'ccls'`
|
||||||
|
|
||||||
This variable can be changed to use a different executable for clangd.
|
This variable can be changed to use a different executable for ccls.
|
||||||
|
|
||||||
|
|
||||||
g:ale_cpp_clangd_options *g:ale_cpp_clangd_options*
|
g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options*
|
||||||
*b:ale_cpp_clangd_options*
|
*b:ale_cpp_ccls_init_options*
|
||||||
Type: |String|
|
Type: |Dictionary|
|
||||||
Default: `''`
|
Default: `{}`
|
||||||
|
|
||||||
This variable can be changed to modify flags given to clangd.
|
This variable can be changed to customize ccls initialization options.
|
||||||
|
Example: >
|
||||||
|
{
|
||||||
|
\ 'cacheDirectory': '/tmp/ccls',
|
||||||
|
\ 'cacheFormat': 'binary',
|
||||||
|
\ 'diagnostics': {
|
||||||
|
\ 'onOpen': 0,
|
||||||
|
\ 'opChange': 1000,
|
||||||
|
\ },
|
||||||
|
\ }
|
||||||
|
<
|
||||||
|
Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all
|
||||||
|
available options and explanations.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
@@ -106,6 +126,25 @@ g:ale_cpp_clangcheck_options *g:ale_cpp_clangcheck_options*
|
|||||||
option.
|
option.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
clangd *ale-cpp-clangd*
|
||||||
|
|
||||||
|
g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable*
|
||||||
|
*b:ale_cpp_clangd_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'clangd'`
|
||||||
|
|
||||||
|
This variable can be changed to use a different executable for clangd.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_cpp_clangd_options *g:ale_cpp_clangd_options*
|
||||||
|
*b:ale_cpp_clangd_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be changed to modify flags given to clangd.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
clang-format *ale-cpp-clangformat*
|
clang-format *ale-cpp-clangformat*
|
||||||
|
|
||||||
@@ -295,61 +334,11 @@ g:ale_cpp_flawfinder_options *g:ale-cpp-flawfinder*
|
|||||||
This variable can be used to pass extra options into the flawfinder command.
|
This variable can be used to pass extra options into the flawfinder command.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
gcc *ale-cpp-gcc*
|
|
||||||
|
|
||||||
g:ale_cpp_gcc_executable *g:ale_cpp_gcc_executable*
|
|
||||||
*b:ale_cpp_gcc_executable*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'gcc'`
|
|
||||||
|
|
||||||
This variable can be changed to use a different executable for gcc.
|
|
||||||
|
|
||||||
|
|
||||||
g:ale_cpp_gcc_options *g:ale_cpp_gcc_options*
|
|
||||||
*b:ale_cpp_gcc_options*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'-std=c++14 -Wall'`
|
|
||||||
|
|
||||||
This variable can be changed to modify flags given to gcc.
|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
uncrustify *ale-cpp-uncrustify*
|
uncrustify *ale-cpp-uncrustify*
|
||||||
|
|
||||||
See |ale-c-uncrustify| for information about the available options.
|
See |ale-c-uncrustify| for information about the available options.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
ccls *ale-cpp-ccls*
|
|
||||||
|
|
||||||
g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable*
|
|
||||||
*b:ale_cpp_ccls_executable*
|
|
||||||
Type: |String|
|
|
||||||
Default: `'ccls'`
|
|
||||||
|
|
||||||
This variable can be changed to use a different executable for ccls.
|
|
||||||
|
|
||||||
|
|
||||||
g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options*
|
|
||||||
*b:ale_cpp_ccls_init_options*
|
|
||||||
Type: |Dictionary|
|
|
||||||
Default: `{}`
|
|
||||||
|
|
||||||
This variable can be changed to customize ccls initialization options.
|
|
||||||
Example: >
|
|
||||||
{
|
|
||||||
\ 'cacheDirectory': '/tmp/ccls',
|
|
||||||
\ 'cacheFormat': 'binary',
|
|
||||||
\ 'diagnostics': {
|
|
||||||
\ 'onOpen': 0,
|
|
||||||
\ 'opChange': 1000,
|
|
||||||
\ },
|
|
||||||
\ }
|
|
||||||
<
|
|
||||||
Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all
|
|
||||||
available options and explanations.
|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Notes:
|
|||||||
* C
|
* C
|
||||||
* `astyle`
|
* `astyle`
|
||||||
* `ccls`
|
* `ccls`
|
||||||
* `clang`
|
* `clang` (`cc`)
|
||||||
* `clangd`
|
* `clangd`
|
||||||
* `clang-format`
|
* `clang-format`
|
||||||
* `clangtidy`!!
|
* `clangtidy`!!
|
||||||
@@ -56,7 +56,7 @@ Notes:
|
|||||||
* `cpplint`!!
|
* `cpplint`!!
|
||||||
* `cquery`
|
* `cquery`
|
||||||
* `flawfinder`
|
* `flawfinder`
|
||||||
* `gcc`
|
* `gcc` (`cc`)
|
||||||
* `uncrustify`
|
* `uncrustify`
|
||||||
* C#
|
* C#
|
||||||
* `csc`!!
|
* `csc`!!
|
||||||
@@ -66,7 +66,7 @@ Notes:
|
|||||||
* C++ (filetype cpp)
|
* C++ (filetype cpp)
|
||||||
* `astyle`
|
* `astyle`
|
||||||
* `ccls`
|
* `ccls`
|
||||||
* `clang`
|
* `clang` (`cc`)
|
||||||
* `clangcheck`!!
|
* `clangcheck`!!
|
||||||
* `clangd`
|
* `clangd`
|
||||||
* `clang-format`
|
* `clang-format`
|
||||||
@@ -76,7 +76,7 @@ Notes:
|
|||||||
* `cpplint`!!
|
* `cpplint`!!
|
||||||
* `cquery`
|
* `cquery`
|
||||||
* `flawfinder`
|
* `flawfinder`
|
||||||
* `gcc`
|
* `gcc` (`cc`)
|
||||||
* `uncrustify`
|
* `uncrustify`
|
||||||
* Chef
|
* Chef
|
||||||
* `cookstyle`
|
* `cookstyle`
|
||||||
|
|||||||
12
doc/ale.txt
12
doc/ale.txt
@@ -2322,16 +2322,15 @@ documented in additional help files.
|
|||||||
bibclean..............................|ale-bib-bibclean|
|
bibclean..............................|ale-bib-bibclean|
|
||||||
c.......................................|ale-c-options|
|
c.......................................|ale-c-options|
|
||||||
astyle................................|ale-c-astyle|
|
astyle................................|ale-c-astyle|
|
||||||
clang.................................|ale-c-clang|
|
cc....................................|ale-c-cc|
|
||||||
|
ccls..................................|ale-c-ccls|
|
||||||
clangd................................|ale-c-clangd|
|
clangd................................|ale-c-clangd|
|
||||||
clang-format..........................|ale-c-clangformat|
|
clang-format..........................|ale-c-clangformat|
|
||||||
clangtidy.............................|ale-c-clangtidy|
|
clangtidy.............................|ale-c-clangtidy|
|
||||||
cppcheck..............................|ale-c-cppcheck|
|
cppcheck..............................|ale-c-cppcheck|
|
||||||
cquery................................|ale-c-cquery|
|
cquery................................|ale-c-cquery|
|
||||||
flawfinder............................|ale-c-flawfinder|
|
flawfinder............................|ale-c-flawfinder|
|
||||||
gcc...................................|ale-c-gcc|
|
|
||||||
uncrustify............................|ale-c-uncrustify|
|
uncrustify............................|ale-c-uncrustify|
|
||||||
ccls..................................|ale-c-ccls|
|
|
||||||
chef....................................|ale-chef-options|
|
chef....................................|ale-chef-options|
|
||||||
cookstyle.............................|ale-chef-cookstyle|
|
cookstyle.............................|ale-chef-cookstyle|
|
||||||
foodcritic............................|ale-chef-foodcritic|
|
foodcritic............................|ale-chef-foodcritic|
|
||||||
@@ -2345,9 +2344,10 @@ documented in additional help files.
|
|||||||
cmake-format..........................|ale-cmake-cmakeformat|
|
cmake-format..........................|ale-cmake-cmakeformat|
|
||||||
cpp.....................................|ale-cpp-options|
|
cpp.....................................|ale-cpp-options|
|
||||||
astyle................................|ale-cpp-astyle|
|
astyle................................|ale-cpp-astyle|
|
||||||
clang.................................|ale-cpp-clang|
|
cc....................................|ale-cpp-cc|
|
||||||
clangd................................|ale-cpp-clangd|
|
ccls..................................|ale-cpp-ccls|
|
||||||
clangcheck............................|ale-cpp-clangcheck|
|
clangcheck............................|ale-cpp-clangcheck|
|
||||||
|
clangd................................|ale-cpp-clangd|
|
||||||
clang-format..........................|ale-cpp-clangformat|
|
clang-format..........................|ale-cpp-clangformat|
|
||||||
clangtidy.............................|ale-cpp-clangtidy|
|
clangtidy.............................|ale-cpp-clangtidy|
|
||||||
clazy.................................|ale-cpp-clazy|
|
clazy.................................|ale-cpp-clazy|
|
||||||
@@ -2355,9 +2355,7 @@ documented in additional help files.
|
|||||||
cpplint...............................|ale-cpp-cpplint|
|
cpplint...............................|ale-cpp-cpplint|
|
||||||
cquery................................|ale-cpp-cquery|
|
cquery................................|ale-cpp-cquery|
|
||||||
flawfinder............................|ale-cpp-flawfinder|
|
flawfinder............................|ale-cpp-flawfinder|
|
||||||
gcc...................................|ale-cpp-gcc|
|
|
||||||
uncrustify............................|ale-cpp-uncrustify|
|
uncrustify............................|ale-cpp-uncrustify|
|
||||||
ccls..................................|ale-cpp-ccls|
|
|
||||||
c#......................................|ale-cs-options|
|
c#......................................|ale-cs-options|
|
||||||
csc...................................|ale-cs-csc|
|
csc...................................|ale-cs-csc|
|
||||||
mcs...................................|ale-cs-mcs|
|
mcs...................................|ale-cs-mcs|
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
Before:
|
Before:
|
||||||
Save g:ale_c_parse_makefile
|
Save g:ale_c_parse_makefile
|
||||||
|
Save g:ale_history_enabled
|
||||||
|
|
||||||
|
let g:ale_c_parse_makefile = 0
|
||||||
|
let g:ale_history_enabled = 0
|
||||||
|
|
||||||
let g:get_cflags_return_value = ''
|
let g:get_cflags_return_value = ''
|
||||||
|
let g:executable_map = {}
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
runtime autoload/ale/c.vim
|
||||||
|
runtime autoload/ale/engine.vim
|
||||||
|
|
||||||
|
function! ale#engine#IsExecutable(buffer, executable) abort
|
||||||
|
return has_key(g:executable_map, a:executable)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale#c#GetCFlags(buffer, output) abort
|
function! ale#c#GetCFlags(buffer, output) abort
|
||||||
return g:get_cflags_return_value
|
return g:get_cflags_return_value
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let g:ale_c_parse_makefile = 0
|
call ale#assert#SetUpLinterTest('c', 'cc')
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('c', 'gcc')
|
|
||||||
|
|
||||||
let b:command_tail = ' -S -x c'
|
let b:command_tail = ' -S -x c'
|
||||||
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
|
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
|
||||||
@@ -19,16 +28,23 @@ Before:
|
|||||||
|
|
||||||
After:
|
After:
|
||||||
unlet! g:get_cflags_return_value
|
unlet! g:get_cflags_return_value
|
||||||
|
unlet! g:executable_map
|
||||||
unlet! b:command_tail
|
unlet! b:command_tail
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
runtime autoload/ale/c.vim
|
||||||
|
runtime autoload/ale/engine.vim
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(clang should be used instead of gcc, if available):
|
||||||
|
let g:executable_map = {'clang': 1}
|
||||||
|
|
||||||
|
AssertLinter 'clang', [ale#Escape('clang') . b:command_tail]
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
AssertLinter 'gcc', [ale#Escape('gcc') . b:command_tail]
|
AssertLinter 'gcc', [ale#Escape('gcc') . b:command_tail]
|
||||||
|
|
||||||
let b:ale_c_gcc_executable = 'foobar'
|
let b:ale_c_cc_executable = 'foobar'
|
||||||
|
|
||||||
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
|
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
Before:
|
|
||||||
Save g:ale_c_parse_makefile
|
|
||||||
let g:ale_c_parse_makefile = 0
|
|
||||||
|
|
||||||
let g:get_cflags_return_value = ''
|
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
|
||||||
|
|
||||||
function! ale#c#GetCFlags(buffer, output) abort
|
|
||||||
return g:get_cflags_return_value
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('c', 'clang')
|
|
||||||
let b:command_tail = ' -S -x c -fsyntax-only -iquote'
|
|
||||||
\ . ' ' . ale#Escape(getcwd())
|
|
||||||
\ . ' -std=c11 -Wall -'
|
|
||||||
|
|
||||||
After:
|
|
||||||
unlet! g:get_cflags_return_value
|
|
||||||
unlet! b:command_tail
|
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
|
||||||
AssertLinter 'clang', [ale#Escape('clang') . b:command_tail]
|
|
||||||
|
|
||||||
let b:ale_c_clang_executable = 'foobar'
|
|
||||||
|
|
||||||
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
|
|
||||||
|
|
||||||
Execute(The -std flag should be replaced by parsed C flags):
|
|
||||||
let b:command_tail = substitute(b:command_tail, 'c11', 'c99 ', '')
|
|
||||||
let g:get_cflags_return_value = '-std=c99'
|
|
||||||
|
|
||||||
AssertLinter 'clang', ale#Escape('clang') . b:command_tail
|
|
||||||
@@ -7,6 +7,7 @@ Before:
|
|||||||
Save g:__ale_c_project_filenames
|
Save g:__ale_c_project_filenames
|
||||||
|
|
||||||
let g:original_project_filenames = g:__ale_c_project_filenames
|
let g:original_project_filenames = g:__ale_c_project_filenames
|
||||||
|
let g:executable_map = {}
|
||||||
|
|
||||||
" Remove the .git/HEAD dir for C import paths for these tests.
|
" Remove the .git/HEAD dir for C import paths for these tests.
|
||||||
" The tests run inside of a git repo.
|
" The tests run inside of a git repo.
|
||||||
@@ -18,17 +19,26 @@ Before:
|
|||||||
let g:ale_c_parse_compile_commands = 0
|
let g:ale_c_parse_compile_commands = 0
|
||||||
let g:ale_c_parse_makefile = 0
|
let g:ale_c_parse_makefile = 0
|
||||||
|
|
||||||
|
runtime autoload/ale/engine.vim
|
||||||
|
|
||||||
|
function! ale#engine#IsExecutable(buffer, executable) abort
|
||||||
|
return has_key(g:executable_map, a:executable)
|
||||||
|
endfunction
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
unlet! g:original_project_filenames
|
unlet! g:original_project_filenames
|
||||||
|
unlet! g:executable_map
|
||||||
|
|
||||||
|
runtime autoload/ale/engine.vim
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The C GCC handler should include 'include' directories for projects with a Makefile):
|
Execute(The C cc linter should include 'include' directories for projects with a Makefile):
|
||||||
call ale#assert#SetUpLinterTest('c', 'gcc')
|
call ale#assert#SetUpLinterTest('c', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
|
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
|
||||||
let g:ale_c_gcc_options = ''
|
let g:ale_c_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -37,10 +47,10 @@ Execute(The C GCC handler should include 'include' directories for projects with
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C GCC handler should include 'include' directories for projects with a configure file):
|
Execute(The C cc linter should include 'include' directories for projects with a configure file):
|
||||||
call ale#assert#SetUpLinterTest('c', 'gcc')
|
call ale#assert#SetUpLinterTest('c', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.c')
|
call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.c')
|
||||||
let g:ale_c_gcc_options = ''
|
let g:ale_c_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -49,10 +59,10 @@ Execute(The C GCC handler should include 'include' directories for projects with
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C GCC handler should include root directories for projects with .h files in them):
|
Execute(The C cc linter should include root directories for projects with .h files in them):
|
||||||
call ale#assert#SetUpLinterTest('c', 'gcc')
|
call ale#assert#SetUpLinterTest('c', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
|
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
|
||||||
let g:ale_c_gcc_options = ''
|
let g:ale_c_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -61,10 +71,10 @@ Execute(The C GCC handler should include root directories for projects with .h f
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C GCC handler should include root directories for projects with .hpp files in them):
|
Execute(The C cc linter should include root directories for projects with .hpp files in them):
|
||||||
call ale#assert#SetUpLinterTest('c', 'gcc')
|
call ale#assert#SetUpLinterTest('c', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c')
|
call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c')
|
||||||
let g:ale_c_gcc_options = ''
|
let g:ale_c_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -73,54 +83,6 @@ Execute(The C GCC handler should include root directories for projects with .hpp
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C Clang handler should include 'include' directories for projects with a Makefile):
|
|
||||||
call ale#assert#SetUpLinterTest('c', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
|
|
||||||
let g:ale_c_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang',
|
|
||||||
\ ale#Escape('clang')
|
|
||||||
\ . ' -S -x c -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C Clang handler should include 'include' directories for projects with a configure file):
|
|
||||||
call ale#assert#SetUpLinterTest('c', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
|
|
||||||
let g:ale_c_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang',
|
|
||||||
\ ale#Escape('clang')
|
|
||||||
\ . ' -S -x c -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C Clang handler should include root directories for projects with .h files in them):
|
|
||||||
call ale#assert#SetUpLinterTest('c', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
|
|
||||||
let g:ale_c_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang',
|
|
||||||
\ ale#Escape('clang')
|
|
||||||
\ . ' -S -x c -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C Clang handler should include root directories for projects with .hpp files in them):
|
|
||||||
call ale#assert#SetUpLinterTest('c', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c')
|
|
||||||
let g:ale_c_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang',
|
|
||||||
\ ale#Escape('clang')
|
|
||||||
\ . ' -S -x c -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C ClangTidy handler should include 'include' directories for projects with a Makefile):
|
Execute(The C ClangTidy handler should include 'include' directories for projects with a Makefile):
|
||||||
call ale#assert#SetUpLinterTest('c', 'clangtidy')
|
call ale#assert#SetUpLinterTest('c', 'clangtidy')
|
||||||
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
|
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
|
||||||
@@ -131,10 +93,10 @@ Execute(The C ClangTidy handler should include 'include' directories for project
|
|||||||
\ . ' %s '
|
\ . ' %s '
|
||||||
\ . '-- -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
|
\ . '-- -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
|
||||||
|
|
||||||
Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile):
|
Execute(The C++ cc linter should include 'include' directories for projects with a Makefile):
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'gcc')
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
|
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
|
||||||
let g:ale_cpp_gcc_options = ''
|
let g:ale_cpp_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -143,10 +105,10 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C++ GCC handler should include 'include' directories for projects with a configure file):
|
Execute(The C++ cc linter should include 'include' directories for projects with a configure file):
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'gcc')
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp')
|
call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp')
|
||||||
let g:ale_cpp_gcc_options = ''
|
let g:ale_cpp_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -155,10 +117,10 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C++ GCC handler should include root directories for projects with .h files in them):
|
Execute(The C++ cc linter should include root directories for projects with .h files in them):
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'gcc')
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp')
|
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp')
|
||||||
let g:ale_cpp_gcc_options = ''
|
let g:ale_cpp_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -167,10 +129,10 @@ Execute(The C++ GCC handler should include root directories for projects with .h
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C++ GCC handler should include root directories for projects with .hpp files in them):
|
Execute(The C++ cc linter should include root directories for projects with .hpp files in them):
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'gcc')
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
||||||
call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp')
|
call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp')
|
||||||
let g:ale_cpp_gcc_options = ''
|
let g:ale_cpp_cc_options = ''
|
||||||
|
|
||||||
AssertLinter 'gcc',
|
AssertLinter 'gcc',
|
||||||
\ ale#Escape('gcc')
|
\ ale#Escape('gcc')
|
||||||
@@ -179,54 +141,6 @@ Execute(The C++ GCC handler should include root directories for projects with .h
|
|||||||
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
|
||||||
\ . ' -'
|
\ . ' -'
|
||||||
|
|
||||||
Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile):
|
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
|
|
||||||
let g:ale_cpp_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang++',
|
|
||||||
\ ale#Escape('clang++')
|
|
||||||
\ . ' -S -x c++ -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C++ Clang handler should include 'include' directories for projects with a configure file):
|
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp')
|
|
||||||
let g:ale_cpp_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang++',
|
|
||||||
\ ale#Escape('clang++')
|
|
||||||
\ . ' -S -x c++ -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C++ Clang handler should include root directories for projects with .h files in them):
|
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp')
|
|
||||||
let g:ale_cpp_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang++',
|
|
||||||
\ ale#Escape('clang++')
|
|
||||||
\ . ' -S -x c++ -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C++ Clang handler should include root directories for projects with .hpp files in them):
|
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'clang')
|
|
||||||
call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp')
|
|
||||||
let g:ale_cpp_clang_options = ''
|
|
||||||
|
|
||||||
AssertLinter 'clang++',
|
|
||||||
\ ale#Escape('clang++')
|
|
||||||
\ . ' -S -x c++ -fsyntax-only'
|
|
||||||
\ . ' -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'))
|
|
||||||
\ . ' -'
|
|
||||||
|
|
||||||
Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them):
|
Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them):
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
|
call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
|
||||||
call ale#test#SetFilename('../test_c_projects/json_project/subdir/file.cpp')
|
call ale#test#SetFilename('../test_c_projects/json_project/subdir/file.cpp')
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
Before:
|
|
||||||
Save g:ale_c_parse_makefile
|
|
||||||
let g:ale_c_parse_makefile = 0
|
|
||||||
|
|
||||||
let g:get_cflags_return_value = ''
|
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
|
||||||
|
|
||||||
function! ale#c#GetCFlags(buffer, output) abort
|
|
||||||
return g:get_cflags_return_value
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'clang')
|
|
||||||
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
|
|
||||||
\ . ' ' . ale#Escape(getcwd())
|
|
||||||
\ . ' -std=c++14 -Wall -'
|
|
||||||
|
|
||||||
After:
|
|
||||||
unlet! g:get_cflags_return_value
|
|
||||||
unlet! b:command_tail
|
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
|
||||||
AssertLinter 'clang++', ale#Escape('clang++') . b:command_tail
|
|
||||||
|
|
||||||
let b:ale_cpp_clang_executable = 'foobar'
|
|
||||||
|
|
||||||
AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
|
|
||||||
|
|
||||||
Execute(The -std flag should be replaced by parsed C flags):
|
|
||||||
let b:command_tail = substitute(b:command_tail, 'c++14', 'c++11 ', '')
|
|
||||||
let g:get_cflags_return_value = '-std=c++11'
|
|
||||||
|
|
||||||
AssertLinter 'clang++', ale#Escape('clang++') . b:command_tail
|
|
||||||
@@ -1,16 +1,26 @@
|
|||||||
Before:
|
Before:
|
||||||
Save g:ale_c_parse_makefile
|
Save g:ale_c_parse_makefile
|
||||||
|
Save g:ale_history_enabled
|
||||||
|
|
||||||
let g:ale_c_parse_makefile = 0
|
let g:ale_c_parse_makefile = 0
|
||||||
|
let g:ale_history_enabled = 0
|
||||||
|
|
||||||
let g:get_cflags_return_value = ''
|
let g:get_cflags_return_value = ''
|
||||||
|
let g:executable_map = {}
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
runtime autoload/ale/c.vim
|
||||||
|
runtime autoload/ale/engine.vim
|
||||||
|
|
||||||
|
function! ale#engine#IsExecutable(buffer, executable) abort
|
||||||
|
return has_key(g:executable_map, a:executable)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale#c#GetCFlags(buffer, output) abort
|
function! ale#c#GetCFlags(buffer, output) abort
|
||||||
return g:get_cflags_return_value
|
return g:get_cflags_return_value
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('cpp', 'gcc')
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
||||||
|
|
||||||
let b:command_tail = ' -S -x c++'
|
let b:command_tail = ' -S -x c++'
|
||||||
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
|
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
|
||||||
\ . ' -iquote ' . ale#Escape(getcwd())
|
\ . ' -iquote ' . ale#Escape(getcwd())
|
||||||
@@ -18,18 +28,25 @@ Before:
|
|||||||
|
|
||||||
After:
|
After:
|
||||||
unlet! g:get_cflags_return_value
|
unlet! g:get_cflags_return_value
|
||||||
|
unlet! g:executable_map
|
||||||
unlet! b:command_tail
|
unlet! b:command_tail
|
||||||
|
|
||||||
runtime autoload/ale/c.vim
|
runtime autoload/ale/c.vim
|
||||||
|
runtime autoload/ale/engine.vim
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(clang++ should be used instead of gcc, if available):
|
||||||
|
let g:executable_map = {'clang++': 1}
|
||||||
|
|
||||||
|
AssertLinter 'clang++', [ale#Escape('clang++') . b:command_tail]
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
|
AssertLinter 'gcc', [ale#Escape('gcc') . b:command_tail]
|
||||||
|
|
||||||
let b:ale_cpp_gcc_executable = 'foobar'
|
let b:ale_cpp_cc_executable = 'foobar'
|
||||||
|
|
||||||
AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
|
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
|
||||||
|
|
||||||
Execute(The -std flag should be replaced by parsed C flags):
|
Execute(The -std flag should be replaced by parsed C flags):
|
||||||
let b:command_tail = substitute(b:command_tail, 'c++14', 'c++11 ', '')
|
let b:command_tail = substitute(b:command_tail, 'c++14', 'c++11 ', '')
|
||||||
|
|||||||
@@ -1,8 +1,19 @@
|
|||||||
Before:
|
Before:
|
||||||
|
Save g:ale_c_build_dir
|
||||||
Save g:ale_c_clangtidy_executable
|
Save g:ale_c_clangtidy_executable
|
||||||
|
Save g:ale_c_clangtidy_checks
|
||||||
|
Save g:ale_c_clangtidy_extra_options
|
||||||
|
Save g:ale_cpp_clangtidy_executable
|
||||||
|
Save g:ale_cpp_clangtidy_checks
|
||||||
|
Save g:ale_cpp_clangtidy_extra_options
|
||||||
|
|
||||||
" Use an invalid global executable, so we don't match it.
|
" Use an invalid global executable, so we don't match it.
|
||||||
let g:ale_c_clangtidy_executable = 'xxxinvalid'
|
let g:ale_c_clangtidy_executable = 'xxxinvalid'
|
||||||
|
let g:ale_c_clangtidy_checks = []
|
||||||
|
let g:ale_c_clangtidy_extra_options = ''
|
||||||
|
let g:ale_cpp_clangtidy_executable = 'xxxinvalidpp'
|
||||||
|
let g:ale_cpp_clangtidy_checks = []
|
||||||
|
let g:ale_cpp_clangtidy_extra_options = ''
|
||||||
let g:ale_c_build_dir = ''
|
let g:ale_c_build_dir = ''
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
@@ -36,16 +47,3 @@ Execute(The clangtidy callback should include any additional options):
|
|||||||
\ . ' -fix -fix-errors --some-option %t',
|
\ . ' -fix -fix-errors --some-option %t',
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#clangtidy#Fix(bufnr(''))
|
\ ale#fixers#clangtidy#Fix(bufnr(''))
|
||||||
|
|
||||||
Execute(The clangtidy callback should support cpp files):
|
|
||||||
call ale#test#SetFilename('c_paths/dummy.cpp')
|
|
||||||
let g:ale_cpp_clangtidy_executable = 'invalidpp'
|
|
||||||
set filetype=cpp " The test fails without this
|
|
||||||
|
|
||||||
AssertEqual
|
|
||||||
\ {
|
|
||||||
\ 'read_temporary_file': 1,
|
|
||||||
\ 'command': ale#Escape(g:ale_cpp_clangtidy_executable)
|
|
||||||
\ . ' -fix -fix-errors %t',
|
|
||||||
\ },
|
|
||||||
\ ale#fixers#clangtidy#Fix(bufnr(''))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user