diff options
Diffstat (limited to 'ale_linters')
26 files changed, 344 insertions, 237 deletions
diff --git a/ale_linters/asm/gcc.vim b/ale_linters/asm/gcc.vim index cbc61ed7..2ef7924e 100644 --- a/ale_linters/asm/gcc.vim +++ b/ale_linters/asm/gcc.vim @@ -1,38 +1,37 @@ " Author: Lucas Kolstad <lkolstad@uw.edu> " Description: gcc linter for asm files -let g:ale_asm_gcc_options = -\ get(g:, 'ale_asm_gcc_options', '-Wall') +let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall') function! ale_linters#asm#gcc#GetCommand(buffer) abort - return 'gcc -x assembler -fsyntax-only ' - \ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ' ' . g:ale_asm_gcc_options . ' -' + return 'gcc -x assembler -fsyntax-only ' + \ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . ' ' . g:ale_asm_gcc_options . ' -' endfunction function! ale_linters#asm#gcc#Handle(buffer, lines) abort - let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match[1] + 0, - \ 'vcol': 0, - \ 'col': 0, - \ 'text': l:match[3], - \ 'type': l:match[2] =~? 'error' ? 'E' : 'W', - \ 'nr': -1, - \}) - endfor - - return l:output + let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': 0, + \ 'text': l:match[3], + \ 'type': l:match[2] =~? 'error' ? 'E' : 'W', + \ 'nr': -1, + \}) + endfor + + return l:output endfunction call ale#linter#Define('asm', { 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/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim index a3a9af2e..e6d1ddb6 100644 --- a/ale_linters/chef/foodcritic.vim +++ b/ale_linters/chef/foodcritic.vim @@ -35,10 +35,10 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort endfunction function! ale_linters#chef#foodcritic#GetCommand(buffer) abort - return printf('%s %s %%t', - \ g:ale_chef_foodcritic_executable, - \ escape(g:ale_chef_foodcritic_options, '~') - \) + return printf('%s %s %%t', + \ g:ale_chef_foodcritic_executable, + \ escape(g:ale_chef_foodcritic_options, '~') + \) endfunction @@ -48,4 +48,3 @@ call ale#linter#Define('chef', { \ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand', \ 'callback': 'ale_linters#chef#foodcritic#Handle', \}) - diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim index f2261c4f..c16a0706 100644 --- a/ale_linters/cpp/gcc.vim +++ b/ale_linters/cpp/gcc.vim @@ -3,15 +3,15 @@ " Set this option to change the GCC options for warnings for C. if !exists('g:ale_cpp_gcc_options') - " added c++14 standard support - " POSIX thread and standard c++ thread and atomic library Linker - " let g:ale_cpp_gcc_options = '-std=c++1z' for c++17 - " for previous version and default, you can just use - " let g:ale_cpp_gcc_options = '-Wall' - " for more see man pages of gcc - " $ man g++ - " make sure g++ in your $PATH - " Add flags according to your requirements + " added c++14 standard support + " POSIX thread and standard c++ thread and atomic library Linker + " let g:ale_cpp_gcc_options = '-std=c++1z' for c++17 + " for previous version and default, you can just use + " let g:ale_cpp_gcc_options = '-Wall' + " for more see man pages of gcc + " $ man g++ + " make sure g++ in your $PATH + " Add flags according to your requirements let g:ale_cpp_gcc_options = '-std=c++14 -Wall' endif diff --git a/ale_linters/crystal/crystal.vim b/ale_linters/crystal/crystal.vim new file mode 100644 index 00000000..8059e776 --- /dev/null +++ b/ale_linters/crystal/crystal.vim @@ -0,0 +1,41 @@ +" Author: Jordan Andree <https://github.com/jordanandree> +" Description: This file adds support for checking Crystal with crystal build + +function! ale_linters#crystal#crystal#Handle(buffer, lines) abort + let l:output = [] + + let l:lines = join(a:lines, '') + + if !empty(l:lines) + let l:errors = json_decode(l:lines) + + for l:error in l:errors + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:error.line + 0, + \ 'col': l:error.column + 0, + \ 'text': l:error.message, + \ 'type': 'E', + \}) + endfor + endif + + return l:output +endfunction + +function! ale_linters#crystal#crystal#GetCommand(buffer) abort + let l:crystal_cmd = 'crystal build -f json --no-codegen -o ' + let l:crystal_cmd .= shellescape(g:ale#util#nul_file) + let l:crystal_cmd .= ' %s' + + return l:crystal_cmd +endfunction + +call ale#linter#Define('crystal', { +\ 'name': 'crystal', +\ 'executable': 'crystal', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\ 'command_callback': 'ale_linters#crystal#crystal#GetCommand', +\ 'callback': 'ale_linters#crystal#crystal#Handle', +\}) diff --git a/ale_linters/dockerfile/hadolint.vim b/ale_linters/dockerfile/hadolint.vim index d0789ae8..df1ac799 100644 --- a/ale_linters/dockerfile/hadolint.vim +++ b/ale_linters/dockerfile/hadolint.vim @@ -1,43 +1,44 @@ " Author: hauleth - https://github.com/hauleth function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort - " Matches patterns line the following: - " - " stdin:19: F: Pipe chain should start with a raw value. - let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:lnum = 0 - - if l:match[1] !=# '' - let l:lnum = l:match[1] + 0 - endif - - let l:type = 'W' - let l:text = l:match[3] - - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:lnum, - \ 'col': 0, - \ 'type': l:type, - \ 'text': l:text, - \ 'nr': l:match[2], - \}) - endfor - - return l:output + " Matches patterns line the following: + " + " stdin:19: F: Pipe chain should start with a raw value. + let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:lnum = 0 + + if l:match[1] !=# '' + let l:lnum = l:match[1] + 0 + endif + + let l:type = 'W' + let l:text = l:match[3] + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:lnum, + \ 'col': 0, + \ 'type': l:type, + \ 'text': l:text, + \ 'nr': l:match[2], + \}) + endfor + + return l:output endfunction call ale#linter#Define('dockerfile', { - \ 'name': 'hadolint', - \ 'executable': 'hadolint', - \ 'command': 'hadolint -', - \ 'callback': 'ale_linters#dockerfile#hadolint#Handle' }) +\ 'name': 'hadolint', +\ 'executable': 'hadolint', +\ 'command': 'hadolint -', +\ 'callback': 'ale_linters#dockerfile#hadolint#Handle', +\}) diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim index 06c2a913..ce34f47c 100644 --- a/ale_linters/elixir/credo.vim +++ b/ale_linters/elixir/credo.vim @@ -1,42 +1,43 @@ " Author: hauleth - https://github.com/hauleth function! ale_linters#elixir#credo#Handle(buffer, lines) abort - " Matches patterns line the following: - " - " lib/filename.ex:19:7: F: Pipe chain should start with a raw value. - let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:type = l:match[3] - let l:text = l:match[4] - - if l:type ==# 'C' - let l:type = 'E' - elseif l:type ==# 'R' - let l:type = 'W' - endif - - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'type': l:type, - \ 'text': l:text, - \}) - endfor - - return l:output + " Matches patterns line the following: + " + " lib/filename.ex:19:7: F: Pipe chain should start with a raw value. + let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:type = l:match[3] + let l:text = l:match[4] + + if l:type ==# 'C' + let l:type = 'E' + elseif l:type ==# 'R' + let l:type = 'W' + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + endfor + + return l:output endfunction call ale#linter#Define('elixir', { - \ 'name': 'credo', - \ 'executable': 'mix', - \ 'command': 'mix credo suggest --format=flycheck --read-from-stdin %s', - \ 'callback': 'ale_linters#elixir#credo#Handle' }) +\ 'name': 'credo', +\ 'executable': 'mix', +\ 'command': 'mix credo suggest --format=flycheck --read-from-stdin %s', +\ 'callback': 'ale_linters#elixir#credo#Handle', +\}) 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/go/gobuild.vim b/ale_linters/go/gobuild.vim index a40565d6..eee0bf84 100644 --- a/ale_linters/go/gobuild.vim +++ b/ale_linters/go/gobuild.vim @@ -4,22 +4,25 @@ " inspired by work from dzhou121 <dzhou121@gmail.com> function! ale_linters#go#gobuild#GoEnv(buffer) abort - if exists('s:go_env') - return '' - endif + if exists('s:go_env') + return '' + endif - return 'go env GOPATH GOROOT' + return 'go env GOPATH GOROOT' endfunction function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort - if !exists('s:go_env') - let s:go_env = { - \ 'GOPATH': a:goenv_output[0], - \ 'GOROOT': a:goenv_output[1], - \} - endif + if !exists('s:go_env') + let s:go_env = { + \ 'GOPATH': a:goenv_output[0], + \ 'GOROOT': a:goenv_output[1], + \} + endif - return 'GOPATH=' . s:go_env.GOPATH . ' go test -c -o /dev/null %s' + " Run go test in local directory with relative path + return 'GOPATH=' . s:go_env.GOPATH + \ . ' cd ' . fnamemodify(bufname(a:buffer), ':.:h') + \ . ' && go test -c -o /dev/null ./' endfunction function! ale_linters#go#gobuild#Handler(buffer, lines) abort @@ -42,7 +45,7 @@ function! ale_linters#go#gobuild#HandleGoBuildErrors(buffer, full_filename, line for l:line in a:lines let l:match = matchlist(l:line, l:pattern) - " Omit errors from imported go packages + " Omit errors from imported go packages if len(l:match) == 0 || l:line !~ l:filename continue endif diff --git a/ale_linters/handlebars/embertemplatelint.vim b/ale_linters/handlebars/embertemplatelint.vim index 7a630e19..68d9ed6c 100644 --- a/ale_linters/handlebars/embertemplatelint.vim +++ b/ale_linters/handlebars/embertemplatelint.vim @@ -27,7 +27,7 @@ endfunction function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort if len(a:lines) == 0 return [] - end + endif let l:output = [] 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 0b8cfc8f..92120970 100644 --- a/ale_linters/nim/nimcheck.vim +++ b/ale_linters/nim/nimcheck.vim @@ -1,11 +1,10 @@ " 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\+\)) \(.\+\)' - let l:output = [] + let l:output = [] for l:line in a:lines let l:match = matchlist(l:line, l:pattern) @@ -51,8 +50,11 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort endfunction -function! ale_linters#nim#nimcheck#GetCommand(buffer) - return 'nim check --path:' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h')) . ' --threads:on --verbosity:0 --colors:off --listFullPaths %t' +function! ale_linters#nim#nimcheck#GetCommand(buffer) abort + 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/ocaml/merlin.vim b/ale_linters/ocaml/merlin.vim index 75cdb126..cfec9966 100644 --- a/ale_linters/ocaml/merlin.vim +++ b/ale_linters/ocaml/merlin.vim @@ -2,12 +2,11 @@ " Description: Report errors in OCaml code with Merlin if !exists('g:merlin') - finish + finish endif function! ale_linters#ocaml#merlin#Handle(buffer, lines) abort - let l:errors = merlin#ErrorLocList() - return l:errors + return merlin#ErrorLocList() endfunction call ale#linter#Define('ocaml', { @@ -16,4 +15,3 @@ call ale#linter#Define('ocaml', { \ 'command': 'true', \ 'callback': 'ale_linters#ocaml#merlin#Handle', \}) - 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/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim index c1aa9536..05763b55 100644 --- a/ale_linters/ruby/rubocop.vim +++ b/ale_linters/ruby/rubocop.vim @@ -32,9 +32,9 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort endfunction function! ale_linters#ruby#rubocop#GetCommand(buffer) abort - return 'rubocop --format emacs --force-exclusion ' . - \ g:ale_ruby_rubocop_options . - \ ' --stdin ' . bufname(a:buffer) + return 'rubocop --format emacs --force-exclusion ' + \ . g:ale_ruby_rubocop_options + \ . ' --stdin ' . bufname(a:buffer) endfunction " Set this option to change Rubocop options. 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/sql/sqlint.vim b/ale_linters/sql/sqlint.vim new file mode 100644 index 00000000..d8bf9dce --- /dev/null +++ b/ale_linters/sql/sqlint.vim @@ -0,0 +1,34 @@ +" Author: Adriaan Zonnenberg <amz@adriaan.xyz> +" Description: sqlint for SQL files + +function! ale_linters#sql#sqlint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " stdin:3:1:ERROR syntax error at or near "WIBBLE" + let l:pattern = '\v^[^:]+:(\d+):(\d+):(\u+) (.*)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if empty(l:match) + continue + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3][0], + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sql', { +\ 'name': 'sqlint', +\ 'executable': 'sqlint', +\ 'command': 'sqlint', +\ 'callback': 'ale_linters#sql#sqlint#Handle', +\}) diff --git a/ale_linters/tex/chktex.vim b/ale_linters/tex/chktex.vim index 95fd2bad..edcfa7d9 100644 --- a/ale_linters/tex/chktex.vim +++ b/ale_linters/tex/chktex.vim @@ -8,49 +8,49 @@ let g:ale_tex_chktex_options = \ get(g:, 'ale_tex_chktex_options', '-I') function! ale_linters#tex#chktex#GetCommand(buffer) abort - " Check for optional .chktexrc - let l:chktex_config = ale#util#FindNearestFile( - \ a:buffer, - \ '.chktexrc') + " Check for optional .chktexrc + let l:chktex_config = ale#util#FindNearestFile( + \ a:buffer, + \ '.chktexrc') - let l:command = g:ale_tex_chktex_executable - " Avoid bug when used without -p (last warning has gibberish for a filename) - let l:command .= ' -v0 -p stdin -q' + let l:command = g:ale_tex_chktex_executable + " Avoid bug when used without -p (last warning has gibberish for a filename) + let l:command .= ' -v0 -p stdin -q' - if !empty(l:chktex_config) - let l:command .= ' -l ' . fnameescape(l:chktex_config) - endif + if !empty(l:chktex_config) + let l:command .= ' -l ' . fnameescape(l:chktex_config) + endif - let l:command .= ' ' . g:ale_tex_chktex_options + let l:command .= ' ' . g:ale_tex_chktex_options - return l:command + return l:command endfunction function! ale_linters#tex#chktex#Handle(buffer, lines) abort - " Mattes lines like: - " - " stdin:499:2:24:Delete this space to maintain correct pagereferences. - " stdin:507:81:3:You should enclose the previous parenthesis with `{}'. - let l:pattern = '^stdin:\(\d\+\):\(\d\+\):\(\d\+\):\(.\+\)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')', - \ 'type': 'W', - \}) - endfor - - return l:output + " Mattes lines like: + " + " stdin:499:2:24:Delete this space to maintain correct pagereferences. + " stdin:507:81:3:You should enclose the previous parenthesis with `{}'. + let l:pattern = '^stdin:\(\d\+\):\(\d\+\):\(\d\+\):\(.\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')', + \ 'type': 'W', + \}) + endfor + + return l:output endfunction call ale#linter#Define('tex', { diff --git a/ale_linters/tex/lacheck.vim b/ale_linters/tex/lacheck.vim index 94b79e6c..300e95d8 100644 --- a/ale_linters/tex/lacheck.vim +++ b/ale_linters/tex/lacheck.vim @@ -13,38 +13,38 @@ function! ale_linters#tex#lacheck#GetCommand(buffer) abort endfunction function! ale_linters#tex#lacheck#Handle(buffer, lines) abort - " Mattes lines like: - " - " "book.tex", line 37: possible unwanted space at "{" - " "book.tex", line 38: missing `\ ' after "etc." - - let l:pattern = '^".\+", line \(\d\+\): \(.\+\)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - " lacheck follows `\input{}` commands. If the cwd is not the same as the - " file in the buffer then it will fail to find the inputed items. We do not - " want warnings from those items anyway - if !empty(matchstr(l:match[2], '^Could not open ".\+"$')) - continue - endif - - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match[1] + 0, - \ 'col': 0, - \ 'text': l:match[2], - \ 'type': 'W', - \}) - endfor - - return l:output + " Mattes lines like: + " + " "book.tex", line 37: possible unwanted space at "{" + " "book.tex", line 38: missing `\ ' after "etc." + + let l:pattern = '^".\+", line \(\d\+\): \(.\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + " lacheck follows `\input{}` commands. If the cwd is not the same as the + " file in the buffer then it will fail to find the inputed items. We do not + " want warnings from those items anyway + if !empty(matchstr(l:match[2], '^Could not open ".\+"$')) + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': 'W', + \}) + endfor + + return l:output endfunction call ale#linter#Define('tex', { 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', \}) |