diff --git a/ale_linters/ansible/ansible-lint.vim b/ale_linters/ansible/ansible-lint.vim index af1e28b..f3bcf56 100644 --- a/ale_linters/ansible/ansible-lint.vim +++ b/ale_linters/ansible/ansible-lint.vim @@ -4,6 +4,6 @@ call ale#linter#Define('ansible', { \ 'name': 'ansible', \ 'executable': 'ansible', -\ 'command': g:ale#util#stdin_wrapper . ' .yml ansible-lint -p', +\ 'command': 'ansible-lint -p %t', \ 'callback': 'ale#handlers#HandlePEP8Format', \}) diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim index d4362cc..754dad7 100644 --- a/ale_linters/c/cppcheck.vim +++ b/ale_linters/c/cppcheck.vim @@ -2,15 +2,14 @@ " Description: cppcheck linter for c files " Set this option to change the cppcheck options -if !exists('g:ale_c_cppcheck_options') - let g:ale_c_cppcheck_options = '--enable=style' -endif +let g:ale_c_cppcheck_options = get(g:, 'ale_c_cppcheck_options', '--enable=style') call ale#linter#Define('c', { \ 'name': 'cppcheck', \ 'output_stream': 'both', \ 'executable': 'cppcheck', -\ 'command': g:ale#util#stdin_wrapper . ' .c cppcheck -q --language=c ' -\ . g:ale_c_cppcheck_options, +\ 'command': 'cppcheck -q --language=c ' +\ . g:ale_c_cppcheck_options +\ . ' %t', \ 'callback': 'ale#handlers#HandleCppCheckFormat', \}) diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim index bfe73c3..0728a37 100644 --- a/ale_linters/chef/foodcritic.vim +++ b/ale_linters/chef/foodcritic.vim @@ -35,7 +35,7 @@ endfunction call ale#linter#Define('chef', { \ 'name': 'foodcritic', \ 'executable': 'foodcritic', -\ 'command': g:ale#util#stdin_wrapper . ' .rb foodcritic', +\ 'command': 'foodcritic %t', \ 'callback': 'ale_linters#chef#foodcritic#Handle', \}) diff --git a/ale_linters/cpp/cppcheck.vim b/ale_linters/cpp/cppcheck.vim index 9576b09..b287715 100644 --- a/ale_linters/cpp/cppcheck.vim +++ b/ale_linters/cpp/cppcheck.vim @@ -2,15 +2,14 @@ " Description: cppcheck linter for cpp files " Set this option to change the cppcheck options -if !exists('g:ale_cpp_cppcheck_options') - let g:ale_cpp_cppcheck_options = '--enable=style' -endif +let g:ale_cpp_cppcheck_options = get(g:, 'ale_cpp_cppcheck_options', '--enable=style') call ale#linter#Define('cpp', { \ 'name': 'cppcheck', \ 'output_stream': 'both', \ 'executable': 'cppcheck', -\ 'command': g:ale#util#stdin_wrapper . ' .cpp cppcheck -q --language=c++ ' -\ . g:ale_cpp_cppcheck_options, +\ 'command': 'cppcheck -q --language=c++ ' +\ . g:ale_cpp_cppcheck_options +\ . ' %t', \ 'callback': 'ale#handlers#HandleCppCheckFormat', \}) diff --git a/ale_linters/cs/mcs.vim b/ale_linters/cs/mcs.vim index edf3bd2..3d39cfb 100644 --- a/ale_linters/cs/mcs.vim +++ b/ale_linters/cs/mcs.vim @@ -1,6 +1,8 @@ -if !exists('g:ale_cs_mcs_options') - let g:ale_cs_mcs_options = '' -endif +let g:ale_cs_mcs_options = get(g:, 'ale_cs_mcs_options', '') + +function! ale_linters#cs#mcs#GetCommand(buffer) abort + return 'mcs -unsafe --parse ' . g:ale_cs_mcs_options . ' %t' +endfunction function! ale_linters#cs#mcs#Handle(buffer, lines) abort " Look for lines like the following. @@ -31,10 +33,9 @@ function! ale_linters#cs#mcs#Handle(buffer, lines) abort endfunction call ale#linter#Define('cs',{ -\ 'name': 'mcs', -\ 'output_stream': 'stderr', -\ 'executable': 'mcs', -\ 'command': g:ale#util#stdin_wrapper . ' .cs mcs -unsafe --parse' . g:ale_cs_mcs_options, -\ 'callback': 'ale_linters#cs#mcs#Handle', -\ }) - +\ 'name': 'mcs', +\ 'output_stream': 'stderr', +\ 'executable': 'mcs', +\ 'command_callback': 'ale_linters#cs#mcs#GetCommand', +\ 'callback': 'ale_linters#cs#mcs#Handle', +\}) diff --git a/ale_linters/css/csslint.vim b/ale_linters/css/csslint.vim index d967f83..39176ce 100644 --- a/ale_linters/css/csslint.vim +++ b/ale_linters/css/csslint.vim @@ -4,6 +4,6 @@ call ale#linter#Define('css', { \ 'name': 'csslint', \ 'executable': 'csslint', -\ 'command': g:ale#util#stdin_wrapper . ' .css csslint --format=compact', +\ 'command': 'csslint --format=compact %t', \ 'callback': 'ale#handlers#HandleCSSLintFormat', \}) diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim index 0c665d7..26e8014 100644 --- a/ale_linters/d/dmd.vim +++ b/ale_linters/d/dmd.vim @@ -46,9 +46,7 @@ function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort endif endfor - return g:ale#util#stdin_wrapper . ' .d dmd ' - \ . join(l:import_list) - \ . ' -o- -vcolumns -c' + return 'dmd '. join(l:import_list) . ' -o- -vcolumns -c %t' endfunction function! ale_linters#d#dmd#Handle(buffer, lines) abort diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim index 35522f1..714272c 100644 --- a/ale_linters/elm/make.vim +++ b/ale_linters/elm/make.vim @@ -52,9 +52,8 @@ function! ale_linters#elm#make#GetCommand(buffer) abort " which is why this is hard coded here. " Source: https://github.com/elm-lang/elm-make/blob/master/src/Flags.hs let l:elm_cmd = 'elm-make --report=json --output='.shellescape('/dev/null') - let l:stdin_wrapper = g:ale#util#stdin_wrapper . ' .elm' - return l:dir_set_cmd . ' ' . l:stdin_wrapper . ' ' . l:elm_cmd + return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t' endfunction call ale#linter#Define('elm', { diff --git a/ale_linters/erlang/erlc.vim b/ale_linters/erlang/erlc.vim index 1cd35d0..571592f 100644 --- a/ale_linters/erlang/erlc.vim +++ b/ale_linters/erlang/erlc.vim @@ -3,7 +3,7 @@ let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '') function! ale_linters#erlang#erlc#GetCommand(buffer) abort - return g:ale#util#stdin_wrapper . ' .erl erlc ' . g:ale_erlang_erlc_options + return 'erlc ' . g:ale_erlang_erlc_options . ' %t' endfunction function! ale_linters#erlang#erlc#Handle(buffer, lines) abort diff --git a/ale_linters/go/gofmt.vim b/ale_linters/go/gofmt.vim index 50d2508..b38e4e9 100644 --- a/ale_linters/go/gofmt.vim +++ b/ale_linters/go/gofmt.vim @@ -5,6 +5,6 @@ call ale#linter#Define('go', { \ 'name': 'gofmt', \ 'output_stream': 'stderr', \ 'executable': 'gofmt', -\ 'command': g:ale#util#stdin_wrapper . ' .go gofmt -e', +\ 'command': 'gofmt -e %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsError', \}) diff --git a/ale_linters/go/golint.vim b/ale_linters/go/golint.vim index 5329e33..8fe5b69 100644 --- a/ale_linters/go/golint.vim +++ b/ale_linters/go/golint.vim @@ -4,6 +4,6 @@ call ale#linter#Define('go', { \ 'name': 'golint', \ 'executable': 'golint', -\ 'command': g:ale#util#stdin_wrapper . ' .go golint', +\ 'command': 'golint %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', \}) diff --git a/ale_linters/go/govet.vim b/ale_linters/go/govet.vim index 6153caa..e605a29 100644 --- a/ale_linters/go/govet.vim +++ b/ale_linters/go/govet.vim @@ -5,6 +5,6 @@ call ale#linter#Define('go', { \ 'name': 'go vet', \ 'output_stream': 'stderr', \ 'executable': 'go', -\ 'command': g:ale#util#stdin_wrapper . ' .go go vet', +\ 'command': 'go vet %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsError', \}) diff --git a/ale_linters/haskell/ghc.vim b/ale_linters/haskell/ghc.vim index 5ddc15f..c14274f 100644 --- a/ale_linters/haskell/ghc.vim +++ b/ale_linters/haskell/ghc.vim @@ -60,7 +60,7 @@ call ale#linter#Define('haskell', { \ 'name': 'ghc', \ 'output_stream': 'stderr', \ 'executable': 'ghc', -\ 'command': g:ale#util#stdin_wrapper . ' .hs ghc -fno-code -v0', +\ 'command': 'ghc -fno-code -v0 %t', \ 'callback': 'ale_linters#haskell#ghc#Handle', \}) @@ -68,6 +68,6 @@ call ale#linter#Define('haskell', { \ 'name': 'stack-ghc', \ 'output_stream': 'stderr', \ 'executable': 'stack', -\ 'command': g:ale#util#stdin_wrapper . ' .hs stack ghc -- -fno-code -v0', +\ 'command': 'stack ghc -- -fno-code -v0 %t', \ 'callback': 'ale_linters#haskell#ghc#Handle', \}) diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim index 910f3e6..c4afcee 100644 --- a/ale_linters/html/htmlhint.vim +++ b/ale_linters/html/htmlhint.vim @@ -23,9 +23,9 @@ function! ale_linters#html#htmlhint#GetExecutable(buffer) abort endfunction function! ale_linters#html#htmlhint#GetCommand(buffer) abort - return g:ale#util#stdin_wrapper . ' .html ' - \ . ale_linters#html#htmlhint#GetExecutable(a:buffer) + return ale_linters#html#htmlhint#GetExecutable(a:buffer) \ . ' ' . g:ale_html_htmlhint_options + \ . ' %t' endfunction call ale#linter#Define('html', { diff --git a/ale_linters/markdown/proselint.vim b/ale_linters/markdown/proselint.vim index fd2155f..065ae32 100644 --- a/ale_linters/markdown/proselint.vim +++ b/ale_linters/markdown/proselint.vim @@ -4,6 +4,6 @@ call ale#linter#Define('markdown', { \ 'name': 'proselint', \ 'executable': 'proselint', -\ 'command': g:ale#util#stdin_wrapper . ' .md proselint', +\ 'command': 'proselint %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', \}) diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim index 302e75c..8eb747e 100644 --- a/ale_linters/matlab/mlint.vim +++ b/ale_linters/matlab/mlint.vim @@ -4,6 +4,16 @@ let g:ale_matlab_mlint_executable = \ get(g:, 'ale_matlab_mlint_executable', 'mlint') +function! ale_linters#matlab#mlint#GetExecutable(buffer) abort + return g:ale_matlab_mlint_executable +endfunction + +function! ale_linters#matlab#mlint#GetCommand(buffer) abort + let l:executable = ale_linters#matlab#mlint#GetExecutable(a:buffer) + + return l:executable . ' -id %t' +endfunction + function! ale_linters#matlab#mlint#Handle(buffer, lines) abort " Matches patterns like the following: " @@ -47,9 +57,8 @@ endfunction call ale#linter#Define('matlab', { \ 'name': 'mlint', -\ 'executable': 'mlint', -\ 'command': g:ale#util#stdin_wrapper . -\ ' .m ' . g:ale_matlab_mlint_executable . ' -id', +\ 'executable_callback': 'ale_linters#matlab#mlint#GetExecutable', +\ 'command_callback': 'ale_linters#matlab#mlint#GetCommand', \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#matlab#mlint#Handle', \}) diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim index 7343253..e7f87bc 100644 --- a/ale_linters/php/phpmd.vim +++ b/ale_linters/php/phpmd.vim @@ -36,6 +36,6 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpmd', \ 'executable': 'phpmd', -\ 'command': g:ale#util#stdin_wrapper . ' .php phpmd %s text ' . g:ale_php_phpmd_ruleset . ' --ignore-violations-on-exit', +\ 'command': 'phpmd %s text ' . g:ale_php_phpmd_ruleset . ' --ignore-violations-on-exit %t', \ 'callback': 'ale_linters#php#phpmd#Handle', \}) diff --git a/ale_linters/pug/puglint.vim b/ale_linters/pug/puglint.vim index 338cb05..4ded7ea 100644 --- a/ale_linters/pug/puglint.vim +++ b/ale_linters/pug/puglint.vim @@ -5,6 +5,6 @@ call ale#linter#Define('pug', { \ 'name': 'puglint', \ 'executable': 'pug-lint', \ 'output_stream': 'stderr', -\ 'command': g:ale#util#stdin_wrapper . ' .pug pug-lint -r inline', +\ 'command': 'pug-lint -r inline %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsError', \}) diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim index 534894c..175d059 100644 --- a/ale_linters/puppet/puppet.vim +++ b/ale_linters/puppet/puppet.vim @@ -33,6 +33,6 @@ call ale#linter#Define('puppet', { \ 'name': 'puppet', \ 'executable': 'puppet', \ 'output_stream': 'stderr', -\ 'command': g:ale#util#stdin_wrapper . ' .pp puppet parser validate --color=false', +\ 'command': 'puppet parser validate --color=false %t', \ 'callback': 'ale_linters#puppet#puppet#Handle', \}) diff --git a/ale_linters/puppet/puppetlint.vim b/ale_linters/puppet/puppetlint.vim index 2d93e53..05745cf 100644 --- a/ale_linters/puppet/puppetlint.vim +++ b/ale_linters/puppet/puppetlint.vim @@ -3,6 +3,8 @@ call ale#linter#Define('puppet', { \ 'name': 'puppetlint', \ 'executable': 'puppet-lint', -\ 'command': g:ale#util#stdin_wrapper . ' .pp puppet-lint --no-autoloader_layout-check --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"', +\ 'command': 'puppet-lint --no-autoloader_layout-check' +\ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"' +\ . ' %t', \ 'callback': 'ale#handlers#HandleGCCFormat', \}) diff --git a/ale_linters/pyrex/cython.vim b/ale_linters/pyrex/cython.vim index 5900431..9168e09 100644 --- a/ale_linters/pyrex/cython.vim +++ b/ale_linters/pyrex/cython.vim @@ -5,8 +5,6 @@ call ale#linter#Define('pyrex', { \ 'name': 'cython', \ 'output_stream': 'stderr', \ 'executable': 'cython', -\ 'command': g:ale#util#stdin_wrapper -\ . ' .pyx cython --warning-extra -o ' -\ . g:ale#util#nul_file, +\ 'command': 'cython --warning-extra -o ' . g:ale#util#nul_file . ' %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsError', \}) diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim index 1509d9e..55ab902 100644 --- a/ale_linters/python/mypy.vim +++ b/ale_linters/python/mypy.vim @@ -10,10 +10,9 @@ function! g:ale_linters#python#mypy#GetCommand(buffer) abort \ ? 'MYPYPATH=' . l:automatic_stubs_dir . ' ' \ : '' - return l:automatic_stubs_command - \ . g:ale#util#stdin_wrapper - \ . ' .py mypy --show-column-numbers ' + return 'mypy --show-column-numbers ' \ . g:ale_python_mypy_options + \ . ' %t' endfunction let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+' diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index f0cd5bd..ada1bfa 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -12,10 +12,10 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort endfunction function! ale_linters#python#pylint#GetCommand(buffer) abort - return g:ale#util#stdin_wrapper . ' .py ' - \ . ale_linters#python#pylint#GetExecutable(a:buffer) + return ale_linters#python#pylint#GetExecutable(a:buffer) \ . ' ' . g:ale_python_pylint_options \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} {msg}" --reports n' + \ . ' %t' endfunction call ale#linter#Define('python', { diff --git a/ale_linters/sass/sasslint.vim b/ale_linters/sass/sasslint.vim index 8c497ed..7d01190 100644 --- a/ale_linters/sass/sasslint.vim +++ b/ale_linters/sass/sasslint.vim @@ -3,6 +3,6 @@ call ale#linter#Define('sass', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', -\ 'command': g:ale#util#stdin_wrapper . ' .sass sass-lint -v -q -f compact', +\ 'command': 'sass-lint -v -q -f compact %t', \ 'callback': 'ale#handlers#HandleCSSLintFormat', \}) diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim index c2e7543..6f46206 100644 --- a/ale_linters/scala/scalac.vim +++ b/ale_linters/scala/scalac.vim @@ -1,4 +1,3 @@ -" vim: set et: " Author: Zoltan Kalmar - https://github.com/kalmiz " Description: Basic scala support using scalac @@ -21,8 +20,10 @@ function! ale_linters#scala#scalac#Handle(buffer, lines) abort let l:text = l:match[3] let l:type = l:match[2] ==# 'error' ? 'E' : 'W' let l:col = 0 + if l:ln + 1 < len(a:lines) let l:col = stridx(a:lines[l:ln + 1], '^') + if l:col == -1 let l:col = 0 endif @@ -47,6 +48,6 @@ call ale#linter#Define('scala', { \ 'name': 'scalac', \ 'executable': 'scalac', \ 'output_stream': 'stderr', -\ 'command': g:ale#util#stdin_wrapper . ' .scala scalac -Ystop-after:parser', +\ 'command': 'scalac -Ystop-after:parser %t', \ 'callback': 'ale_linters#scala#scalac#Handle', \}) diff --git a/ale_linters/scss/sasslint.vim b/ale_linters/scss/sasslint.vim index 0b78f3b..ee4fdbb 100644 --- a/ale_linters/scss/sasslint.vim +++ b/ale_linters/scss/sasslint.vim @@ -3,6 +3,6 @@ call ale#linter#Define('scss', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', -\ 'command': g:ale#util#stdin_wrapper . ' .scss sass-lint -v -q -f compact', +\ 'command': 'sass-lint -v -q -f compact %t', \ 'callback': 'ale#handlers#HandleCSSLintFormat', \}) diff --git a/ale_linters/tex/lacheck.vim b/ale_linters/tex/lacheck.vim index ffa1daa..848cbed 100644 --- a/ale_linters/tex/lacheck.vim +++ b/ale_linters/tex/lacheck.vim @@ -4,6 +4,14 @@ let g:ale_tex_lacheck_executable = \ get(g:, 'ale_tex_lacheck_executable', 'lacheck') +function! ale_linters#tex#lacheck#GetExecutable(buffer) abort + return g:ale_tex_lacheck_executable +endfunction + +function! ale_linters#tex#lacheck#GetCommand(buffer) abort + return g:ale_tex_lacheck_executable . ' %t' +endfunction + function! ale_linters#tex#lacheck#Handle(buffer, lines) abort " Mattes lines like: " @@ -43,8 +51,7 @@ endfunction call ale#linter#Define('tex', { \ 'name': 'lacheck', -\ 'executable': 'lacheck', -\ 'command': g:ale#util#stdin_wrapper . ' .tex ' -\ . g:ale_tex_lacheck_executable, +\ 'executable_callback': 'ale_linters#tex#lacheck#GetExecutable', +\ 'command_callback': 'ale_linters#tex#lacheck#GetCommand', \ 'callback': 'ale_linters#tex#lacheck#Handle' \}) diff --git a/ale_linters/tex/proselint.vim b/ale_linters/tex/proselint.vim index d175c88..6801cf3 100644 --- a/ale_linters/tex/proselint.vim +++ b/ale_linters/tex/proselint.vim @@ -4,6 +4,6 @@ call ale#linter#Define('tex', { \ 'name': 'proselint', \ 'executable': 'proselint', -\ 'command': g:ale#util#stdin_wrapper . ' .tex proselint', +\ 'command': 'proselint %t', \ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', \}) diff --git a/ale_linters/text/proselint.vim b/ale_linters/text/proselint.vim index f84462d..9bfbb2c 100644 --- a/ale_linters/text/proselint.vim +++ b/ale_linters/text/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('text', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', -\ 'command': g:ale#util#stdin_wrapper . ' .txt proselint', +\ 'command': 'proselint %t', \}) diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index eb5b1a7..ae41ed4 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -38,13 +38,11 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#typescript#tslint#BuildLintCommand(buffer_n) abort - let l:tsconfig_path = ale#util#FindNearestFile(a:buffer_n, 'tslint.json') +function! ale_linters#typescript#tslint#BuildLintCommand(buffer) abort + let l:tsconfig_path = ale#util#FindNearestFile(a:buffer, 'tslint.json') let l:tslint_options = empty(l:tsconfig_path) ? '' : '-c ' . l:tsconfig_path - let l:ext = '.' . fnamemodify(bufname(a:buffer_n), ':e') - - return g:ale#util#stdin_wrapper . ' ' . l:ext . ' tslint ' . l:tslint_options + return 'tslint ' . l:tslint_options . ' %t' endfunction call ale#linter#Define('typescript', { diff --git a/ale_linters/verilog/iverilog.vim b/ale_linters/verilog/iverilog.vim index d10661d..cf1b0fa 100644 --- a/ale_linters/verilog/iverilog.vim +++ b/ale_linters/verilog/iverilog.vim @@ -40,6 +40,6 @@ call ale#linter#Define('verilog', { \ 'name': 'iverilog', \ 'output_stream': 'stderr', \ 'executable': 'iverilog', -\ 'command': g:ale#util#stdin_wrapper . ' .v iverilog -t null -Wall', +\ 'command': 'iverilog -t null -Wall %t', \ 'callback': 'ale_linters#verilog#iverilog#Handle', \}) diff --git a/ale_linters/verilog/verilator.vim b/ale_linters/verilog/verilator.vim index 534e1ae..4ff2093 100644 --- a/ale_linters/verilog/verilator.vim +++ b/ale_linters/verilog/verilator.vim @@ -1,6 +1,16 @@ " Author: Masahiro H https://github.com/mshr-h " Description: verilator for verilog files +function! ale_linters#verilog#verilator#GetCommand(buffer) abort + let l:filename = tempname() . '_verilator_linted.v' + + " Create a special filename, so we can detect it in the handler. + call ale#engine#ManageFile(a:buffer, l:filename) + call writefile(getbufline(a:buffer, 1, '$'), l:filename) + + return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' . fnameescape(l:filename) +endfunction + function! ale_linters#verilog#verilator#Handle(buffer, lines) abort " Look for lines like the following. " @@ -25,16 +35,16 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort let l:text = l:match[4] let l:file = l:match[2] - if(l:file =~# '_verilator_linted.v') - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:line, - \ 'vcol': 0, - \ 'col': 1, - \ 'text': l:text, - \ 'type': l:type, - \ 'nr': -1, - \}) + if l:file =~# '_verilator_linted.v' + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:line, + \ 'vcol': 0, + \ 'col': 1, + \ 'text': l:text, + \ 'type': l:type, + \ 'nr': -1, + \}) endif endfor @@ -45,6 +55,7 @@ call ale#linter#Define('verilog', { \ 'name': 'verilator', \ 'output_stream': 'stderr', \ 'executable': 'verilator', -\ 'command': g:ale#util#stdin_wrapper . ' _verilator_linted.v verilator --lint-only -Wall -Wno-DECLFILENAME', +\ 'command_callback': 'ale_linters#verilog#verilator#GetCommand', \ 'callback': 'ale_linters#verilog#verilator#Handle', +\ 'read_buffer': 0, \}) diff --git a/ale_linters/vim/vint.vim b/ale_linters/vim/vint.vim index bc6ea46..9917f3f 100644 --- a/ale_linters/vim/vint.vim +++ b/ale_linters/vim/vint.vim @@ -12,11 +12,11 @@ let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {desc call ale#linter#Define('vim', { \ 'name': 'vint', \ 'executable': 'vint', -\ 'command': g:ale#util#stdin_wrapper -\ . ' .vim vint ' +\ 'command': 'vint ' \ . s:warning_flag \ . ' --no-color ' \ . s:enable_neovim -\ . s:format, +\ . s:format +\ . ' %t', \ 'callback': 'ale#handlers#HandleGCCFormat', \}) diff --git a/ale_linters/yaml/yamllint.vim b/ale_linters/yaml/yamllint.vim index 05af709..0a1ca7d 100644 --- a/ale_linters/yaml/yamllint.vim +++ b/ale_linters/yaml/yamllint.vim @@ -37,6 +37,6 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'yamllint', \ 'executable': 'yamllint', -\ 'command': g:ale#util#stdin_wrapper . ' .yml yamllint -f parsable', +\ 'command': 'yamllint -f parsable %t', \ 'callback': 'ale_linters#yaml#yamllint#Handle', \}) diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index 6c6f20b..6367489 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -1,23 +1,6 @@ " Author: w0rp " Description: Contains miscellaneous functions -function! s:FindWrapperScript() abort - for l:parent in split(&runtimepath, ',') - " Expand the path to deal with ~ issues. - let l:path = expand(l:parent . '/' . 'stdin-wrapper') - - if filereadable(l:path) - if has('win32') - return l:path . '.exe' - endif - - return l:path - endif - endfor -endfunction - -let g:ale#util#stdin_wrapper = s:FindWrapperScript() - " A null file for sending output to nothing. let g:ale#util#nul_file = '/dev/null' diff --git a/stdin-wrapper b/stdin-wrapper deleted file mode 100755 index de4af0e..0000000 --- a/stdin-wrapper +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Authors: w0rp , hauleth -# Description: This script implements a wrapper for any program which does not accept -# stdin input on most Unix machines. The input to the script is read to a -# temporary file, and the first argument sets a particular file extension -# for the temporary file. - -set -eu - -# All of the following arguments are read as command to run. -file_extension="$1" -shift - -temp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'ale_linter') -temp_file="$temp_dir/file$file_extension" -trap 'rm -r "$temp_dir"' EXIT - -cat > "$temp_file" - -"$@" "$temp_file" diff --git a/stdin-wrapper.exe b/stdin-wrapper.exe deleted file mode 100644 index d79f678..0000000 Binary files a/stdin-wrapper.exe and /dev/null differ diff --git a/stdin_wrapper.d b/stdin_wrapper.d deleted file mode 100644 index 8714bc2..0000000 --- a/stdin_wrapper.d +++ /dev/null @@ -1,84 +0,0 @@ -// Author: w0rp -// Description: This file provides a D program for implementing -// the stdin-wrapper on Windows. - -import std.algorithm; -import std.array; -import std.file; -import std.process; -import std.stdio; -import std.path; - -@safe -auto createTemporaryFilename(string fileExtension) { - import std.uuid; - - string filename; - - do { - const randomPart = randomUUID().toString.replace("-", "_"); - - filename = buildPath(tempDir(), "ale_" ~ randomPart ~ fileExtension); - } while (exists(filename)); - - return filename; -} - -@trusted -void readStdinToFile(ref File tempFile) { - stdin.byChunk(4096).copy(tempFile.lockingTextWriter()); -} - -// Expand program names like "csslint" to "csslint.cmd" -// D is not able to perform this kind of expanstion in spawnProcess -@safe -string expandedProgramName(string name) { - auto extArray = environment["PATHEXT"].split(";"); - - foreach(pathDir; environment["PATH"].split(";")) { - foreach(extension; extArray) { - const candidate = buildPath(pathDir, name ~ extension); - - if (exists(candidate)) { - return candidate; - } - } - } - - // We were given a full path for a program name, so use that. - if (exists(name)) { - return name; - } - - return ""; -} - -@trusted -int runLinterProgram(string[] args) { - const expandedName = expandedProgramName(args[0]); - - writeln(expandedName); - - if (expandedName) { - return wait(spawnProcess([expandedName] ~ args[1..$])); - } - - return 1; -} - -@safe -int main(string[] args) { - const filename = createTemporaryFilename(args[1]); - - auto tempFile = File(filename, "w"); - - scope(exit) { - tempFile.close(); - remove(filename); - } - - readStdinToFile(tempFile); - tempFile.close(); - - return runLinterProgram(args[2..$] ~ [filename]); -} diff --git a/test/test_stdin_wrapper_path_can_be_found.vader b/test/test_stdin_wrapper_path_can_be_found.vader deleted file mode 100644 index cf13bca..0000000 --- a/test/test_stdin_wrapper_path_can_be_found.vader +++ /dev/null @@ -1,4 +0,0 @@ -Execute(We should be able to find the stdin-wrapper script): - silent! cd /testplugin/test - - AssertEqual expand('%:p:h:h') . '/stdin-wrapper', ale#util#stdin_wrapper