diff options
Diffstat (limited to 'ale_linters')
30 files changed, 269 insertions, 160 deletions
diff --git a/ale_linters/bib/bibclean.vim b/ale_linters/bib/bibclean.vim index 6750f22f..1c6b55d0 100644 --- a/ale_linters/bib/bibclean.vim +++ b/ale_linters/bib/bibclean.vim @@ -11,9 +11,9 @@ endfunction function! ale_linters#bib#bibclean#get_type(str) abort if a:str is# '??' - return 'E' + return 'E' else - return 'W' + return 'W' endif endfunction @@ -36,30 +36,31 @@ function! ale_linters#bib#bibclean#Handle(buffer, lines) abort let l:msg = '' for l:line in a:lines - if empty(l:msg) - let l:mlist = ale_linters#bib#bibclean#match_msg(l:line) + if empty(l:msg) + let l:mlist = ale_linters#bib#bibclean#match_msg(l:line) - if !empty(l:mlist) - let l:msg = l:mlist[3] - let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1]) - endif - else - if l:type is# 'E' - let l:mlist = ale_linters#bib#bibclean#match_entry(l:line) - else - let l:mlist = ale_linters#bib#bibclean#match_value(l:line) - endif + if !empty(l:mlist) + let l:msg = l:mlist[3] + let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1]) + endif + else + if l:type is# 'E' + let l:mlist = ale_linters#bib#bibclean#match_entry(l:line) + else + let l:mlist = ale_linters#bib#bibclean#match_value(l:line) + endif - if !empty(l:mlist) - call add(l:output, { - \ 'lnum': l:mlist[1], - \ 'col': l:mlist[2], - \ 'text': l:msg, - \ 'type': l:type - \}) - let l:msg = '' - endif - endif + if !empty(l:mlist) + call add(l:output, { + \ 'lnum': l:mlist[1], + \ 'col': l:mlist[2], + \ 'text': l:msg, + \ 'type': l:type + \}) + + let l:msg = '' + endif + endif endfor return l:output diff --git a/ale_linters/c/flawfinder.vim b/ale_linters/c/flawfinder.vim index 7e1f6769..94104141 100644 --- a/ale_linters/c/flawfinder.vim +++ b/ale_linters/c/flawfinder.vim @@ -7,13 +7,13 @@ call ale#Set('c_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_error_severity', 6) function! ale_linters#c#flawfinder#GetCommand(buffer) abort - " Set the minimum vulnerability level for flawfinder to bother with - let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') + " Set the minimum vulnerability level for flawfinder to bother with + let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') - return '%e -CDQS' - \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) - \ . l:minlevel - \ . ' %t' + return '%e -CDQS' + \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) + \ . l:minlevel + \ . ' %t' endfunction call ale#linter#Define('c', { diff --git a/ale_linters/clojure/joker.vim b/ale_linters/clojure/joker.vim index 2f61148b..1f17cd31 100644 --- a/ale_linters/clojure/joker.vim +++ b/ale_linters/clojure/joker.vim @@ -11,7 +11,7 @@ function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort let l:type = 'E' if l:match[4] is? 'Parse warning' - let l:type = 'W' + let l:type = 'W' endif call add(l:output, { diff --git a/ale_linters/cpp/flawfinder.vim b/ale_linters/cpp/flawfinder.vim index 4f669bff..0a966604 100644 --- a/ale_linters/cpp/flawfinder.vim +++ b/ale_linters/cpp/flawfinder.vim @@ -7,13 +7,13 @@ call ale#Set('cpp_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_error_severity', 6) function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort - " Set the minimum vulnerability level for flawfinder to bother with - let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') + " Set the minimum vulnerability level for flawfinder to bother with + let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') - return '%e -CDQS' - \ . ale#Var(a:buffer, 'cpp_flawfinder_options') - \ . l:minlevel - \ . ' %t' + return '%e -CDQS' + \ . ale#Var(a:buffer, 'cpp_flawfinder_options') + \ . l:minlevel + \ . ' %t' endfunction call ale#linter#Define('cpp', { diff --git a/ale_linters/crystal/ameba.vim b/ale_linters/crystal/ameba.vim index 165cabd0..a1bf9c1d 100644 --- a/ale_linters/crystal/ameba.vim +++ b/ale_linters/crystal/ameba.vim @@ -14,7 +14,7 @@ endfunction " Handle output from ameba function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort if len(a:lines) == 0 - return [] + return [] endif let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {}) @@ -32,7 +32,7 @@ function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort let l:end_col = str2nr(l:error['end_location']['column']) if !l:end_col - let l:end_col = l:start_col + 1 + let l:end_col = l:start_col + 1 endif call add(l:output, { diff --git a/ale_linters/cypher/cypher_lint.vim b/ale_linters/cypher/cypher_lint.vim new file mode 100644 index 00000000..408ddd6e --- /dev/null +++ b/ale_linters/cypher/cypher_lint.vim @@ -0,0 +1,26 @@ +" Author: Francisco Lopes <francisco@oblita.com> +" Description: Linting for Neo4j's Cypher + +function! ale_linters#cypher#cypher_lint#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+): (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('cypher', { +\ 'name': 'cypher_lint', +\ 'executable': 'cypher-lint', +\ 'command': 'cypher-lint', +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#cypher#cypher_lint#Handle', +\}) diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim index 325689fe..190f7541 100644 --- a/ale_linters/elm/make.vim +++ b/ale_linters/elm/make.vim @@ -222,10 +222,10 @@ function! ale_linters#elm#make#GetExecutable(buffer) abort if l:is_test && l:is_v19 return ale#node#FindExecutable( -\ a:buffer, -\ 'elm_make', -\ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] -\ ) + \ a:buffer, + \ 'elm_make', + \ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] + \) else return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) endif diff --git a/ale_linters/go/langserver.vim b/ale_linters/go/langserver.vim index df956483..e049be7b 100644 --- a/ale_linters/go/langserver.vim +++ b/ale_linters/go/langserver.vim @@ -10,8 +10,8 @@ function! ale_linters#go#langserver#GetCommand(buffer) abort let l:options = substitute(l:options, '-gocodecompletion', '', 'g') let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1') - if(ale#Var(a:buffer, 'completion_enabled') == 1) - call add(l:options, '-gocodecompletion') + if ale#Var(a:buffer, 'completion_enabled') + call add(l:options, '-gocodecompletion') endif let l:options = uniq(sort(l:options)) diff --git a/ale_linters/hack/hhast.vim b/ale_linters/hack/hhast.vim index 710b7b25..f6870b59 100644 --- a/ale_linters/hack/hhast.vim +++ b/ale_linters/hack/hhast.vim @@ -9,7 +9,7 @@ function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig') if empty(l:hhconfig) - return '' + return '' endif let l:root = fnamemodify(l:hhconfig, ':h') diff --git a/ale_linters/haskell/hie.vim b/ale_linters/haskell/hie.vim index 3ff1180a..cc85fbed 100644 --- a/ale_linters/haskell/hie.vim +++ b/ale_linters/haskell/hie.vim @@ -9,33 +9,27 @@ function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort " If it's empty, search for the cabal file if empty(l:project_file) - let l:cabal_file = fnamemodify(bufname(a:buffer), ':p:h') - let l:paths = '' - - while empty(matchstr(l:cabal_file, '^\(\/\|\(\w:\\\)\)$')) - let l:cabal_file = fnamemodify(l:cabal_file, ':h') - let l:paths = l:paths . l:cabal_file . ',' - endwhile - + " Search all of the paths except for the root filesystem path. + let l:paths = join( + \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2], + \ ',' + \) let l:project_file = globpath(l:paths, '*.cabal') endif - " Either extract the project directory or take the current working - " directory - if !empty(l:project_file) - let l:project_file = fnamemodify(l:project_file, ':h') - else - let l:project_file = expand('#' . a:buffer . ':p:h') + " If we still can't find one, use the current file. + if empty(l:project_file) + let l:project_file = expand('#' . a:buffer . ':p') endif - return l:project_file + return fnamemodify(l:project_file, ':h') endfunction function! ale_linters#haskell#hie#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'haskell_hie_executable') return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie') -\ . ' --lsp' + \ . ' --lsp' endfunction call ale#linter#Define('haskell', { diff --git a/ale_linters/idris/idris.vim b/ale_linters/idris/idris.vim index feac0f10..42b88158 100644 --- a/ale_linters/idris/idris.vim +++ b/ale_linters/idris/idris.vim @@ -49,11 +49,11 @@ function! ale_linters#idris#idris#Handle(buffer, lines) abort let l:errors = matchlist(l:match[5], '\v([wW]arning|[eE]rror) - ?(.*)') if len(l:errors) > 0 - let l:ghc_type = l:errors[1] - let l:text = l:errors[2] + let l:ghc_type = l:errors[1] + let l:text = l:errors[2] else - let l:ghc_type = '' - let l:text = l:match[5][:0] is# ' ' ? l:match[5][1:] : l:match[5] + let l:ghc_type = '' + let l:text = l:match[5][:0] is# ' ' ? l:match[5][1:] : l:match[5] endif if l:ghc_type is? 'Warning' diff --git a/ale_linters/java/javalsp.vim b/ale_linters/java/javalsp.vim index 1436a52c..6329ab3c 100644 --- a/ale_linters/java/javalsp.vim +++ b/ale_linters/java/javalsp.vim @@ -1,7 +1,6 @@ " Author: Horacio Sanson <https://github.com/hsanson> " Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac -call ale#Set('java_javalsp_jar', 'javacs.jar') call ale#Set('java_javalsp_executable', 'java') function! ale_linters#java#javalsp#Executable(buffer) abort @@ -9,10 +8,9 @@ function! ale_linters#java#javalsp#Executable(buffer) abort endfunction function! ale_linters#java#javalsp#Command(buffer) abort - let l:jar = ale#Var(a:buffer, 'java_javalsp_jar') let l:executable = ale_linters#java#javalsp#Executable(a:buffer) - return ale#Escape(l:executable) . ' -cp ' . l:jar . ' -Xverify:none org.javacs.Main' + return ale#Escape(l:executable) . ' -Xverify:none -m javacs/org.javacs.Main' endfunction call ale#linter#Define('java', { diff --git a/ale_linters/kotlin/kotlinc.vim b/ale_linters/kotlin/kotlinc.vim index 4a993986..32dcc6d1 100644 --- a/ale_linters/kotlin/kotlinc.vim +++ b/ale_linters/kotlin/kotlinc.vim @@ -20,7 +20,7 @@ function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort if !empty(l:pom_path) && executable('mvn') return ale#path#CdString(fnamemodify(l:pom_path, ':h')) - \ . 'mvn dependency:build-classpath' + \ . 'mvn dependency:build-classpath' endif let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer) diff --git a/ale_linters/markdown/markdownlint.vim b/ale_linters/markdown/markdownlint.vim index 5c8af650..e935cbfe 100644 --- a/ale_linters/markdown/markdownlint.vim +++ b/ale_linters/markdown/markdownlint.vim @@ -2,10 +2,10 @@ " Description: Adds support for markdownlint call ale#linter#Define('markdown', { - \ 'name': 'markdownlint', - \ 'executable': 'markdownlint', - \ 'lint_file': 1, - \ 'output_stream': 'both', - \ 'command': 'markdownlint %s', - \ 'callback': 'ale#handlers#markdownlint#Handle' -\ }) +\ 'name': 'markdownlint', +\ 'executable': 'markdownlint', +\ 'lint_file': 1, +\ 'output_stream': 'both', +\ 'command': 'markdownlint %s', +\ 'callback': 'ale#handlers#markdownlint#Handle' +\}) diff --git a/ale_linters/perl6/perl6.vim b/ale_linters/perl6/perl6.vim index b33a0c51..39406ac4 100644 --- a/ale_linters/perl6/perl6.vim +++ b/ale_linters/perl6/perl6.vim @@ -36,8 +36,8 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort endif if has_key(a:dict[a:item], 'line') && !empty(a:dict[a:item]['line']) - let l:line = a:dict[a:item]['line'] - let l:counter -= 1 + let l:line = a:dict[a:item]['line'] + let l:counter -= 1 endif if has_key(a:dict[a:item], 'column') && !empty(a:dict[a:item]['column']) @@ -61,7 +61,7 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort " Currently, filenames and line numbers are not always given in the error output if l:counter < 2 - \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' ) + \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' ) return { \ 'lnum': '' . l:line, \ 'text': l:text, @@ -83,7 +83,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort endif if a:lines[0] is# 'Syntax OK' - return l:output + return l:output endif try @@ -101,8 +101,8 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort if type(l:json) is v:t_dict for l:key in keys(l:json) - if has_key(l:json[l:key], 'sorrows') && - \ has_key(l:json[l:key], 'worries') + if has_key(l:json[l:key], 'sorrows') + \&& has_key(l:json[l:key], 'worries') if !empty(l:json[l:key]['sorrows']) for l:dictionary in get(l:json[l:key], 'sorrows') for l:item in keys(l:dictionary) @@ -115,7 +115,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort \ ) if l:result isnot# '' - call add(l:output, l:result) + call add(l:output, l:result) endif endfor endfor @@ -133,7 +133,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort \ ) if l:result isnot# '' - call add(l:output, l:result) + call add(l:output, l:result) endif endfor endfor @@ -147,7 +147,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort \ ) if l:result isnot# '' - call add(l:output, l:result) + call add(l:output, l:result) endif endif endfor diff --git a/ale_linters/prolog/swipl.vim b/ale_linters/prolog/swipl.vim index 401e52b6..77261ede 100644 --- a/ale_linters/prolog/swipl.vim +++ b/ale_linters/prolog/swipl.vim @@ -87,8 +87,8 @@ endfunction " Skip sandbox error which is caused by directives " because what we want is syntactic or semantic check. function! s:Ignore(item) abort - return a:item.type is# 'E' && - \ a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' + return a:item.type is# 'E' + \ && a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' endfunction call ale#linter#Define('prolog', { diff --git a/ale_linters/python/bandit.vim b/ale_linters/python/bandit.vim index 1b5a84a4..819c83aa 100644 --- a/ale_linters/python/bandit.vim +++ b/ale_linters/python/bandit.vim @@ -7,9 +7,10 @@ call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('python_bandit_auto_pipenv', 0) function! ale_linters#python#bandit#GetExecutable(buffer) abort - if (ale#Var(a:buffer, 'python_auto_pipenv') || - \ ale#Var(a:buffer, 'python_bandit_auto_pipenv')) - \ && ale#python#PipenvPresent(a:buffer) + if ( + \ ale#Var(a:buffer, 'python_auto_pipenv') + \ || ale#Var(a:buffer, 'python_bandit_auto_pipenv') + \) && ale#python#PipenvPresent(a:buffer) return 'pipenv' endif diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index b5b5f3cc..076bd9c4 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -74,15 +74,11 @@ let s:end_col_pattern_map = { \} function! ale_linters#python#flake8#Handle(buffer, lines) abort - for l:line in a:lines[:10] - if match(l:line, '^Traceback') >= 0 - return [{ - \ 'lnum': 1, - \ 'text': 'An exception was thrown. See :ALEDetail', - \ 'detail': join(a:lines, "\n"), - \}] - endif - endfor + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif " Matches patterns line the following: " @@ -90,7 +86,6 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort " " stdin:6:6: E111 indentation is not a multiple of four let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+):? (.*)$' - let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:code = l:match[3] diff --git a/ale_linters/python/pylama.vim b/ale_linters/python/pylama.vim new file mode 100644 index 00000000..52b7c8c8 --- /dev/null +++ b/ale_linters/python/pylama.vim @@ -0,0 +1,94 @@ +" Author: Kevin Locke <kevin@kevinlocke.name> +" Description: pylama for python files + +call ale#Set('python_pylama_executable', 'pylama') +call ale#Set('python_pylama_options', '') +call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pylama_auto_pipenv', 0) +call ale#Set('python_pylama_change_directory', 1) + +function! ale_linters#python#pylama#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylama_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama']) +endfunction + +function! ale_linters#python#pylama#GetCommand(buffer) abort + let l:cd_string = '' + + if ale#Var(a:buffer, 'python_pylama_change_directory') + " Pylama loads its configuration from the current directory only, and + " applies file masks using paths relative to the current directory. + " Run from project root, if found, otherwise buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + let l:cd_string = l:project_root isnot# '' + \ ? ale#path#CdString(l:project_root) + \ : ale#path#BufferCdString(a:buffer) + endif + + let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run pylama' + \ : '' + + return l:cd_string + \ . ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options')) + \ . ' %t' +endfunction + +function! ale_linters#python#pylama#Handle(buffer, lines) abort + if empty(a:lines) + return [] + endif + + let l:output = ale#python#HandleTraceback(a:lines, 1) + let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$' + + " First letter of error code is a pylint-compatible message type + " http://pylint.pycqa.org/en/latest/user_guide/output.html#source-code-analysis-section + " D is for Documentation (pydocstyle) + let l:pylint_type_to_ale_type = { + \ 'I': 'I', + \ 'R': 'W', + \ 'C': 'W', + \ 'W': 'W', + \ 'E': 'E', + \ 'F': 'E', + \ 'D': 'W', + \} + let l:pylint_type_to_ale_sub_type = { + \ 'R': 'style', + \ 'C': 'style', + \ 'D': 'style', + \} + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " Ignore C0103 for module name from temporary path (%t) which may not + " comply with module-rgx. + if l:match[3] is# 'C0103' && l:match[4] =~# '^Module name ' + continue + endif + + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'code': l:match[3], + \ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'), + \ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''), + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pylama', +\ 'executable_callback': 'ale_linters#python#pylama#GetExecutable', +\ 'command_callback': 'ale_linters#python#pylama#GetCommand', +\ 'callback': 'ale_linters#python#pylama#Handle', +\}) diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index 01c3cb37..da845b7a 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -53,7 +53,7 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort if l:code is# 'I0011' " Skip 'Locally disabling' message - continue + continue endif call add(l:output, { diff --git a/ale_linters/python/vulture.vim b/ale_linters/python/vulture.vim index 80828013..b3908b80 100644 --- a/ale_linters/python/vulture.vim +++ b/ale_linters/python/vulture.vim @@ -46,19 +46,14 @@ endfunction function! ale_linters#python#vulture#Handle(buffer, lines) abort - for l:line in a:lines[:10] - if match(l:line, '^Traceback') >= 0 - return [{ - \ 'lnum': 1, - \ 'text': 'An exception was thrown. See :ALEDetail', - \ 'detail': join(a:lines, "\n"), - \}] - endif - endfor + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif " Matches patterns line the following: let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (.*)$' - let l:output = [] let l:dir = s:GetDir(a:buffer) for l:match in ale#util#GetMatches(a:lines, l:pattern) diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index 0f68e62c..12864722 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -8,6 +8,7 @@ " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) call ale#Set('sh_shellcheck_executable', 'shellcheck') +call ale#Set('sh_shellcheck_dialect', 'auto') call ale#Set('sh_shellcheck_options', '') function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort @@ -53,9 +54,13 @@ function! ale_linters#sh#shellcheck#GetCommand(buffer, version_output) abort let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') - let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) + let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect') let l:external_option = ale#semver#GTE(l:version, [0, 4, 0]) ? ' -x' : '' + if l:dialect is# 'auto' + let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) + endif + return ale#path#BufferCdString(a:buffer) \ . ale#Escape(l:executable) \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') diff --git a/ale_linters/slim/slimlint.vim b/ale_linters/slim/slimlint.vim index 00c6b26c..a27736f8 100644 --- a/ale_linters/slim/slimlint.vim +++ b/ale_linters/slim/slimlint.vim @@ -11,11 +11,11 @@ function! ale_linters#slim#slimlint#GetCommand(buffer) abort " " See https://github.com/sds/slim-lint/blob/master/lib/slim_lint/linter/README.md#rubocop if !empty(l:rubocop_config) - if ale#Has('win32') - let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command - else - let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command - endif + if ale#Has('win32') + let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command + else + let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command + endif endif return l:command diff --git a/ale_linters/swift/swiftlint.vim b/ale_linters/swift/swiftlint.vim index a1150658..0f2ea8de 100644 --- a/ale_linters/swift/swiftlint.vim +++ b/ale_linters/swift/swiftlint.vim @@ -6,10 +6,10 @@ call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [ - \ 'Pods/SwiftLint/swiftlint', - \ 'ios/Pods/SwiftLint/swiftlint', - \ 'swiftlint', - \]) + \ 'Pods/SwiftLint/swiftlint', + \ 'ios/Pods/SwiftLint/swiftlint', + \ 'swiftlint', + \]) endfunction function! ale_linters#swift#swiftlint#GetCommand(buffer) abort @@ -17,7 +17,7 @@ function! ale_linters#swift#swiftlint#GetCommand(buffer) abort let l:args = 'lint --use-stdin' return ale#Escape(l:executable) - \ . ' ' .l:args + \ . ' ' .l:args endfunction function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort @@ -26,10 +26,10 @@ function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:item = { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:match[4] is# 'error' ? 'E' : 'W', - \ 'text': l:match[5], - \} + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'text': l:match[5], + \} if l:match[4] is# 'error' let l:item.type = 'E' diff --git a/ale_linters/verilog/vlog.vim b/ale_linters/verilog/vlog.vim index 1a1fcb6a..c7686291 100644 --- a/ale_linters/verilog/vlog.vim +++ b/ale_linters/verilog/vlog.vim @@ -17,11 +17,11 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', - \ 'text': l:match[3], - \}) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[3], + \}) endfor return l:output diff --git a/ale_linters/verilog/xvlog.vim b/ale_linters/verilog/xvlog.vim index db2227cd..52498f8f 100644 --- a/ale_linters/verilog/xvlog.vim +++ b/ale_linters/verilog/xvlog.vim @@ -16,11 +16,11 @@ function! ale_linters#verilog#xvlog#Handle(buffer, lines) abort " NOTE: `xvlog` only prints 'INFO' and 'ERROR' messages for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'type': 'E', - \ 'text': l:match[1], - \}) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': 'E', + \ 'text': l:match[1], + \}) endfor return l:output diff --git a/ale_linters/vhdl/ghdl.vim b/ale_linters/vhdl/ghdl.vim index 2aef6cd5..c21be242 100644 --- a/ale_linters/vhdl/ghdl.vim +++ b/ale_linters/vhdl/ghdl.vim @@ -6,7 +6,7 @@ call ale#Set('vhdl_ghdl_executable', 'ghdl') call ale#Set('vhdl_ghdl_options', '--std=08') function! ale_linters#vhdl#ghdl#GetCommand(buffer) abort - return '%e -s ' . ale#Pad(ale#Var(a:buffer, 'vhdl_ghdl_options')) . ' %t' + return '%e -s ' . ale#Pad(ale#Var(a:buffer, 'vhdl_ghdl_options')) . ' %t' endfunction function! ale_linters#vhdl#ghdl#Handle(buffer, lines) abort diff --git a/ale_linters/vhdl/vcom.vim b/ale_linters/vhdl/vcom.vim index 3df5633e..e4631b68 100644 --- a/ale_linters/vhdl/vcom.vim +++ b/ale_linters/vhdl/vcom.vim @@ -19,11 +19,11 @@ function! ale_linters#vhdl#vcom#Handle(buffer, lines) abort let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', - \ 'text': l:match[3], - \}) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[3], + \}) endfor return l:output diff --git a/ale_linters/vhdl/xvhdl.vim b/ale_linters/vhdl/xvhdl.vim index c8336eac..6e0d411d 100644 --- a/ale_linters/vhdl/xvhdl.vim +++ b/ale_linters/vhdl/xvhdl.vim @@ -18,11 +18,11 @@ function! ale_linters#vhdl#xvhdl#Handle(buffer, lines) abort " NOTE: `xvhdl` only prints 'INFO' and 'ERROR' messages for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'type': 'E', - \ 'text': l:match[1], - \}) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': 'E', + \ 'text': l:match[1], + \}) endfor return l:output diff --git a/ale_linters/xml/xmllint.vim b/ale_linters/xml/xmllint.vim index 59f43d16..b003b096 100644 --- a/ale_linters/xml/xmllint.vim +++ b/ale_linters/xml/xmllint.vim @@ -29,27 +29,27 @@ function! ale_linters#xml#xmllint#Handle(buffer, lines) abort let l:match_message = matchlist(l:line, l:pattern_message) if !empty(l:match_message) - let l:line = l:match_message[2] + 0 - let l:type = l:match_message[4] =~? 'warning' ? 'W' : 'E' - let l:text = l:match_message[3] + let l:line = l:match_message[2] + 0 + let l:type = l:match_message[4] =~? 'warning' ? 'W' : 'E' + let l:text = l:match_message[3] - call add(l:output, { - \ 'lnum': l:line, - \ 'text': l:text, - \ 'type': l:type, - \}) + call add(l:output, { + \ 'lnum': l:line, + \ 'text': l:text, + \ 'type': l:type, + \}) - continue + continue endif " Parse column position let l:match_column_token = matchlist(l:line, l:pattern_column_token) if !empty(l:output) && !empty(l:match_column_token) - let l:previous = l:output[len(l:output) - 1] - let l:previous['col'] = len(l:match_column_token[0]) + let l:previous = l:output[len(l:output) - 1] + let l:previous['col'] = len(l:match_column_token[0]) - continue + continue endif endfor |