diff options
author | w0rp <devw0rp@gmail.com> | 2017-07-16 22:11:43 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-07-16 22:11:43 +0100 |
commit | 58717e05a3af56e8937dc5e794523e3184d5d530 (patch) | |
tree | 4ac3d54ded848bb075c6c4c0d1171eb1a3ee6c5c /ale_linters | |
parent | 54ff57317455994305b8bba085c5db166dc34373 (diff) | |
download | ale-58717e05a3af56e8937dc5e794523e3184d5d530.zip |
#711 - Make the cppcheck executables configurable
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/c/cppcheck.vim | 13 | ||||
-rw-r--r-- | ale_linters/cpp/cppcheck.vim | 13 |
2 files changed, 18 insertions, 8 deletions
diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim index 90805914..4db93f74 100644 --- a/ale_linters/c/cppcheck.vim +++ b/ale_linters/c/cppcheck.vim @@ -1,8 +1,12 @@ " Author: Bart Libert <bart.libert@gmail.com> " Description: cppcheck linter for c files -" Set this option to change the cppcheck options -let g:ale_c_cppcheck_options = get(g:, 'ale_c_cppcheck_options', '--enable=style') +call ale#Set('c_cppcheck_executable', 'cppcheck') +call ale#Set('c_cppcheck_options', '--enable=style') + +function! ale_linters#c#cppcheck#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'c_cppcheck_executable') +endfunction function! ale_linters#c#cppcheck#GetCommand(buffer) abort " Search upwards from the file for compile_commands.json. @@ -19,7 +23,8 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort \ : '' return l:cd_command - \ . 'cppcheck -q --language=c ' + \ . ale#Escape(ale_linters#c#cppcheck#GetExecutable(a:buffer)) + \ . ' -q --language=c ' \ . l:compile_commands_option \ . ale#Var(a:buffer, 'c_cppcheck_options') \ . ' %t' @@ -28,7 +33,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'cppcheck', \ 'output_stream': 'both', -\ 'executable': 'cppcheck', +\ 'executable_callback': 'ale_linters#c#cppcheck#GetExecutable', \ 'command_callback': 'ale_linters#c#cppcheck#GetCommand', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/ale_linters/cpp/cppcheck.vim b/ale_linters/cpp/cppcheck.vim index 2255f63f..8b2aa802 100644 --- a/ale_linters/cpp/cppcheck.vim +++ b/ale_linters/cpp/cppcheck.vim @@ -1,8 +1,12 @@ " Author: Bart Libert <bart.libert@gmail.com> " Description: cppcheck linter for cpp files -" Set this option to change the cppcheck options -let g:ale_cpp_cppcheck_options = get(g:, 'ale_cpp_cppcheck_options', '--enable=style') +call ale#Set('cpp_cppcheck_executable', 'cppcheck') +call ale#Set('cpp_cppcheck_options', '--enable=style') + +function! ale_linters#cpp#cppcheck#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'cpp_cppcheck_executable') +endfunction function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort " Search upwards from the file for compile_commands.json. @@ -19,7 +23,8 @@ function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort \ : '' return l:cd_command - \ . 'cppcheck -q --language=c++ ' + \ . ale#Escape(ale_linters#cpp#cppcheck#GetExecutable(a:buffer)) + \ . ' -q --language=c++ ' \ . l:compile_commands_option \ . ale#Var(a:buffer, 'cpp_cppcheck_options') \ . ' %t' @@ -28,7 +33,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'cppcheck', \ 'output_stream': 'both', -\ 'executable': 'cppcheck', +\ 'executable_callback': 'ale_linters#cpp#cppcheck#GetExecutable', \ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) |