summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/clangtidy.vim20
-rw-r--r--ale_linters/cpp/clangtidy.vim20
-rw-r--r--ale_linters/cpp/clazy.vim32
3 files changed, 34 insertions, 38 deletions
diff --git a/ale_linters/c/clangtidy.vim b/ale_linters/c/clangtidy.vim
index 84c103e6..54137480 100644
--- a/ale_linters/c/clangtidy.vim
+++ b/ale_linters/c/clangtidy.vim
@@ -16,27 +16,9 @@ call ale#Set('c_clangtidy_checks', ['*'])
call ale#Set('c_clangtidy_options', '')
call ale#Set('c_build_dir', '')
-function! s: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')
-
- " c_build_dir has the priority if defined
- if !empty(l:build_dir)
- return l:build_dir
- endif
-
- return ale#path#Dirname(ale#c#FindCompileCommands(a:buffer))
-endfunction
-
function! ale_linters#c#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
- let l:build_dir = s:GetBuildDirectory(a:buffer)
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
" Get the extra options if we couldn't find a build directory.
let l:options = empty(l:build_dir)
diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim
index 930087a8..2f3089b4 100644
--- a/ale_linters/cpp/clangtidy.vim
+++ b/ale_linters/cpp/clangtidy.vim
@@ -10,27 +10,9 @@ call ale#Set('cpp_clangtidy_checks', ['*'])
call ale#Set('cpp_clangtidy_options', '')
call ale#Set('c_build_dir', '')
-function! s: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')
-
- " c_build_dir has the priority if defined
- if !empty(l:build_dir)
- return l:build_dir
- endif
-
- return ale#path#Dirname(ale#c#FindCompileCommands(a:buffer))
-endfunction
-
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',')
- let l:build_dir = s:GetBuildDirectory(a:buffer)
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
" Get the extra options if we couldn't find a build directory.
let l:options = empty(l:build_dir)
diff --git a/ale_linters/cpp/clazy.vim b/ale_linters/cpp/clazy.vim
new file mode 100644
index 00000000..cbbd0ccf
--- /dev/null
+++ b/ale_linters/cpp/clazy.vim
@@ -0,0 +1,32 @@
+" Description: clazy linter for cpp files (clang-based and Qt-oriented)
+
+call ale#Set('cpp_clazy_executable', 'clazy-standalone')
+" Set this option to check the checks clazy will apply.
+call ale#Set('cpp_clazy_checks', ['level1'])
+" Set this option to manually set some options for clazy.
+" This will disable compile_commands.json detection.
+call ale#Set('cpp_clazy_options', '')
+call ale#Set('c_build_dir', '')
+
+function! ale_linters#cpp#clazy#GetCommand(buffer) abort
+ let l:checks = join(ale#Var(a:buffer, 'cpp_clazy_checks'), ',')
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
+
+ " Get the extra options if we couldn't find a build directory.
+ let l:options = ale#Var(a:buffer, 'cpp_clazy_options')
+
+ return '%e'
+ \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
+ \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' %s'
+endfunction
+
+call ale#linter#Define('cpp', {
+\ 'name': 'clazy',
+\ 'output_stream': 'stderr',
+\ 'executable_callback': ale#VarFunc('cpp_clazy_executable'),
+\ 'command_callback': 'ale_linters#cpp#clazy#GetCommand',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'lint_file': 1,
+\})