summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-04-15 13:35:54 +0100
committerw0rp <devw0rp@gmail.com>2017-04-15 13:36:16 +0100
commit706dd050f2ec570eb12398d42a18f6c4f2bd56df (patch)
tree2c463aa0d5ef02feab3f2ef87215bd4417b47729
parent2f009690c3cf442f828830cc1d2fece619f308ff (diff)
downloadale-706dd050f2ec570eb12398d42a18f6c4f2bd56df.zip
Fix #257 in preparation for #427, standardise options with fallbacks, and make it so every value can be computed dynamically
-rw-r--r--ale_linters/c/cppcheck.vim10
-rw-r--r--ale_linters/elm/make.vim1
-rw-r--r--ale_linters/erlang/erlc.vim1
-rw-r--r--ale_linters/fortran/gcc.vim10
-rw-r--r--ale_linters/html/tidy.vim14
-rw-r--r--ale_linters/lua/luacheck.vim13
-rw-r--r--ale_linters/nim/nimcheck.vim6
-rw-r--r--ale_linters/nix/nix.vim1
-rw-r--r--ale_linters/php/phpmd.vim8
-rw-r--r--ale_linters/python/flake8.vim6
-rw-r--r--ale_linters/python/mypy.vim2
-rw-r--r--ale_linters/sml/smlnj.vim6
-rw-r--r--ale_linters/vim/vint.vim19
-rwxr-xr-xcustom-checks2
-rw-r--r--doc/ale-html.txt2
-rw-r--r--doc/ale-python.txt4
16 files changed, 69 insertions, 36 deletions
diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim
index 754dad70..7b89bee4 100644
--- a/ale_linters/c/cppcheck.vim
+++ b/ale_linters/c/cppcheck.vim
@@ -4,12 +4,16 @@
" Set this option to change the cppcheck options
let g:ale_c_cppcheck_options = get(g:, 'ale_c_cppcheck_options', '--enable=style')
+function! ale_linters#c#cppcheck#GetCommand(buffer) abort
+ return 'cppcheck -q --language=c '
+ \ . g:ale_c_cppcheck_options
+ \ . ' %t'
+endfunction
+
call ale#linter#Define('c', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
\ 'executable': 'cppcheck',
-\ 'command': 'cppcheck -q --language=c '
-\ . g:ale_c_cppcheck_options
-\ . ' %t',
+\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#HandleCppCheckFormat',
\})
diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim
index 3a4febc9..a8ae4b1a 100644
--- a/ale_linters/elm/make.vim
+++ b/ale_linters/elm/make.vim
@@ -62,4 +62,3 @@ call ale#linter#Define('elm', {
\ 'command_callback': 'ale_linters#elm#make#GetCommand',
\ 'callback': 'ale_linters#elm#make#Handle'
\})
-
diff --git a/ale_linters/erlang/erlc.vim b/ale_linters/erlang/erlc.vim
index d6adf126..5ec04106 100644
--- a/ale_linters/erlang/erlc.vim
+++ b/ale_linters/erlang/erlc.vim
@@ -5,6 +5,7 @@ let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
let l:output_file = tempname()
call ale#engine#ManageFile(a:buffer, l:output_file)
+
return 'erlc -o ' . fnameescape(l:output_file) . ' ' . g:ale_erlang_erlc_options . ' %t'
endfunction
diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim
index 6d3f495c..0f390852 100644
--- a/ale_linters/fortran/gcc.vim
+++ b/ale_linters/fortran/gcc.vim
@@ -52,12 +52,16 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
return l:output
endfunction
+function! ale_linters#fortran#gcc#GetCommand(buffer) abort
+ return 'gcc -S -x f95 -fsyntax-only -ffree-form '
+ \ . g:ale_fortran_gcc_options
+ \ . ' -'
+endfunction
+
call ale#linter#Define('fortran', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable': 'gcc',
-\ 'command': 'gcc -S -x f95 -fsyntax-only -ffree-form '
-\ . g:ale_fortran_gcc_options
-\ . ' -',
+\ 'command_callback': 'ale_linters#fortran#gcc#GetCommand',
\ 'callback': 'ale_linters#fortran#gcc#Handle',
\})
diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim
index 9067f9d4..eab07a0f 100644
--- a/ale_linters/html/tidy.vim
+++ b/ale_linters/html/tidy.vim
@@ -3,7 +3,9 @@
" CLI options
let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy')
-let g:ale_html_tidy_args = get(g:, 'ale_html_tidy_args', '-q -e -language en')
+" Look for the old _args variable first.
+let s:default_options = get(g:, 'ale_html_tidy_args', '-q -e -language en')
+let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', s:default_options)
function! ale_linters#html#tidy#GetCommand(buffer) abort
" Specify file encoding in options
@@ -25,9 +27,13 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort
return printf('%s %s %s -',
\ g:ale_html_tidy_executable,
- \ g:ale_html_tidy_args,
+ \ g:ale_html_tidy_options,
\ l:file_encoding
- \ )
+ \)
+endfunction
+
+function! ale_linters#html#tidy#GetExecutable(buffer) abort
+ return g:ale_html_tidy_executable
endfunction
function! ale_linters#html#tidy#Handle(buffer, lines) abort
@@ -63,7 +69,7 @@ endfunction
call ale#linter#Define('html', {
\ 'name': 'tidy',
-\ 'executable': g:ale_html_tidy_executable,
+\ 'executable_callback': 'ale_linters#html#tidy#GetExecutable',
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#html#tidy#GetCommand',
\ 'callback': 'ale_linters#html#tidy#Handle',
diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim
index e208c93b..ab590911 100644
--- a/ale_linters/lua/luacheck.vim
+++ b/ale_linters/lua/luacheck.vim
@@ -4,6 +4,15 @@
let g:ale_lua_luacheck_executable =
\ get(g:, 'ale_lua_luacheck_executable', 'luacheck')
+function! ale_linters#lua#luacheck#GetExecutable(buffer) abort
+ return g:ale_lua_luacheck_executable
+endfunction
+
+function! ale_linters#lua#luacheck#GetCommand(buffer) abort
+ return ale_linters#lua#luacheck#GetExecutable(a:buffer)
+ \ . ' --formatter plain --codes --filename %s -'
+endfunction
+
function! ale_linters#lua#luacheck#Handle(buffer, lines) abort
" Matches patterns line the following:
"
@@ -33,7 +42,7 @@ endfunction
call ale#linter#Define('lua', {
\ 'name': 'luacheck',
-\ 'executable': g:ale_lua_luacheck_executable,
-\ 'command': g:ale_lua_luacheck_executable . ' --formatter plain --codes --filename %s -',
+\ 'executable_callback': 'ale_linters#lua#luacheck#GetExecutable',
+\ 'command_callback': 'ale_linters#lua#luacheck#GetCommand',
\ 'callback': 'ale_linters#lua#luacheck#Handle',
\})
diff --git a/ale_linters/nim/nimcheck.vim b/ale_linters/nim/nimcheck.vim
index 0d3a1b51..92120970 100644
--- a/ale_linters/nim/nimcheck.vim
+++ b/ale_linters/nim/nimcheck.vim
@@ -1,7 +1,6 @@
" Author: Baabelfish
" Description: Typechecking for nim files
-
function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t')
let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)'
@@ -52,7 +51,10 @@ endfunction
function! ale_linters#nim#nimcheck#GetCommand(buffer) abort
- return 'nim check --path:' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h')) . ' --threads:on --verbosity:0 --colors:off --listFullPaths %t'
+ let l:directory = fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
+
+ return 'nim check --path:' . l:directory
+ \ . ' --threads:on --verbosity:0 --colors:off --listFullPaths %t'
endfunction
diff --git a/ale_linters/nix/nix.vim b/ale_linters/nix/nix.vim
index 27c1d51a..96baa3b8 100644
--- a/ale_linters/nix/nix.vim
+++ b/ale_linters/nix/nix.vim
@@ -2,7 +2,6 @@
" Description: nix-instantiate linter for nix files
function! ale_linters#nix#nix#Handle(buffer, lines) abort
-
let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\d\+\):\(\d\+\)$'
let l:output = []
diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim
index c8d1b79d..9426fcc3 100644
--- a/ale_linters/php/phpmd.vim
+++ b/ale_linters/php/phpmd.vim
@@ -4,6 +4,12 @@
" Set to change the ruleset
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode')
+function! ale_linters#php#phpmd#GetCommand(buffer) abort
+ return 'phpmd %s text '
+ \ . g:ale_php_phpmd_ruleset
+ \ . ' --ignore-violations-on-exit %t'
+endfunction
+
function! ale_linters#php#phpmd#Handle(buffer, lines) abort
" Matches against lines like the following:
"
@@ -33,6 +39,6 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpmd',
\ 'executable': 'phpmd',
-\ 'command': 'phpmd %s text ' . g:ale_php_phpmd_ruleset . ' --ignore-violations-on-exit %t',
+\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
\ 'callback': 'ale_linters#php#phpmd#Handle',
\})
diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim
index bd136b27..378d6b53 100644
--- a/ale_linters/python/flake8.vim
+++ b/ale_linters/python/flake8.vim
@@ -4,8 +4,10 @@
let g:ale_python_flake8_executable =
\ get(g:, 'ale_python_flake8_executable', 'flake8')
-let g:ale_python_flake8_args =
-\ get(g:, 'ale_python_flake8_args', '')
+" Support an old setting as a fallback.
+let s:default_options = get(g:, 'ale_python_flake8_args', '')
+let g:ale_python_flake8_options =
+\ get(g:, 'ale_python_flake8_options', s:default_options)
" A map from Python executable paths to semver strings parsed for those
" executables, so we don't have to look up the version number constantly.
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index 187bb83c..c60c0607 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -53,7 +53,7 @@ function! g:ale_linters#python#mypy#Handle(buffer, lines) abort
return l:output
endfunction
-call g:ale#linter#Define('python', {
+call ale#linter#Define('python', {
\ 'name': 'mypy',
\ 'executable': 'mypy',
\ 'command_callback': 'ale_linters#python#mypy#GetCommand',
diff --git a/ale_linters/sml/smlnj.vim b/ale_linters/sml/smlnj.vim
index b1599521..48786370 100644
--- a/ale_linters/sml/smlnj.vim
+++ b/ale_linters/sml/smlnj.vim
@@ -1,12 +1,6 @@
" Author: Paulo Alem <paulo.alem@gmail.com>
" Description: Rudimentary SML checking with smlnj compiler
-if exists('g:loaded_ale_sml_smlnj_checker')
- finish
-endif
-
-let g:loaded_ale_sml_smlnj_checker = 1
-
function! ale_linters#sml#smlnj#Handle(buffer, lines) abort
" Try to match basic sml errors
diff --git a/ale_linters/vim/vint.vim b/ale_linters/vim/vint.vim
index 821a0bdc..05ec2424 100644
--- a/ale_linters/vim/vint.vim
+++ b/ale_linters/vim/vint.vim
@@ -5,20 +5,25 @@
let g:ale_vim_vint_show_style_issues =
\ get(g:, 'ale_vim_vint_show_style_issues', 1)
-let s:warning_flag = g:ale_vim_vint_show_style_issues ? '-s' : '-w'
let s:vint_version = ale#semver#Parse(system('vint --version'))
let s:has_no_color_support = ale#semver#GreaterOrEqual(s:vint_version, [0, 3, 7])
let s:enable_neovim = has('nvim') ? ' --enable-neovim ' : ''
let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})"'
+function! ale_linters#vim#vint#GetCommand(buffer) abort
+ let l:warning_flag = g:ale_vim_vint_show_style_issues ? '-s' : '-w'
+
+ return 'vint '
+ \ . l:warning_flag . ' '
+ \ . (s:has_no_color_support ? '--no-color ' : '')
+ \ . s:enable_neovim
+ \ . s:format
+ \ . ' %t'
+endfunction
+
call ale#linter#Define('vim', {
\ 'name': 'vint',
\ 'executable': 'vint',
-\ 'command': 'vint '
-\ . s:warning_flag . ' '
-\ . (s:has_no_color_support ? '--no-color ' : '')
-\ . s:enable_neovim
-\ . s:format
-\ . ' %t',
+\ 'command_callback': 'ale_linters#vim#vint#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\})
diff --git a/custom-checks b/custom-checks
index ee7cdea6..440dafe5 100755
--- a/custom-checks
+++ b/custom-checks
@@ -71,5 +71,7 @@ check_errors ' \+$' 'Trailing whitespace'
check_errors '^ * end\?i\? *$' 'Write endif, not en, end, or endi'
check_errors '^ [^ ]' 'Use four spaces, not two spaces'
check_errors $'\t' 'Use four spaces, not tabs'
+# This check should prevent people from using a particular inconsistent name.
+check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<lintername>_options instead'
exit $RETURN_CODE
diff --git a/doc/ale-html.txt b/doc/ale-html.txt
index 06ee2df1..3d428b3b 100644
--- a/doc/ale-html.txt
+++ b/doc/ale-html.txt
@@ -47,7 +47,7 @@ g:ale_html_tidy_executable *g:ale_html_tidy_executable*
This variable can be changed to change the path to tidy.
-g:ale_html_tidy_args *g:ale_html_tidy_args*
+g:ale_html_tidy_options *g:ale_html_tidy_options*
Type: |String|
Default: `'-q -e -language en'`
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index 77e9e1b1..698f3912 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -13,7 +13,7 @@ g:ale_python_flake8_executable *g:ale_python_flake8_executable*
This variable can be changed to modify the executable used for flake8.
-g:ale_python_flake8_args *g:ale_python_flake8_args*
+g:ale_python_flake8_options *g:ale_python_flake8_options*
Type: |String|
Default: `''`
@@ -25,7 +25,7 @@ g:ale_python_flake8_args *g:ale_python_flake8_args*
Python 3, you may want to set >
let g:ale_python_flake8_executable = 'python3' " or 'python' for Python 2
- let g:ale_python_flake8_args = '-m flake8'
+ let g:ale_python_flake8_options = '-m flake8'
<
after making sure it's installed for the appropriate Python versions (e.g.
`python3 -m pip install --user flake8`).