diff options
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/c/clang.vim | 11 | ||||
-rw-r--r-- | ale_linters/c/gcc.vim | 11 | ||||
-rw-r--r-- | ale_linters/cpp/clang.vim | 11 | ||||
-rw-r--r-- | ale_linters/cpp/gcc.vim | 11 | ||||
-rw-r--r-- | ale_linters/fish/fish.vim | 59 | ||||
-rw-r--r-- | ale_linters/go/gosimple.vim | 8 | ||||
-rw-r--r-- | ale_linters/go/gotype.vim | 25 | ||||
-rw-r--r-- | ale_linters/go/govet.vim | 19 | ||||
-rw-r--r-- | ale_linters/go/staticcheck.vim | 2 | ||||
-rw-r--r-- | ale_linters/markdown/markdownlint.vim | 11 | ||||
-rw-r--r-- | ale_linters/markdown/remark_lint.vim | 18 | ||||
-rw-r--r-- | ale_linters/markdown/textlint.vim | 9 | ||||
-rw-r--r-- | ale_linters/po/msgfmt.vim | 2 | ||||
-rw-r--r-- | ale_linters/qml/qmllint.vim | 29 | ||||
-rw-r--r-- | ale_linters/text/textlint.vim | 9 | ||||
-rw-r--r-- | ale_linters/typescript/tslint.vim | 2 |
16 files changed, 164 insertions, 73 deletions
diff --git a/ale_linters/c/clang.vim b/ale_linters/c/clang.vim index 76803056..ddec4fcb 100644 --- a/ale_linters/c/clang.vim +++ b/ale_linters/c/clang.vim @@ -8,15 +8,15 @@ function! ale_linters#c#clang#GetExecutable(buffer) abort return ale#Var(a:buffer, 'c_clang_executable') endfunction -function! ale_linters#c#clang#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +function! ale_linters#c#clang#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer)) \ . ' -S -x c -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags \ . ale#Var(a:buffer, 'c_clang_options') . ' -' endfunction @@ -24,6 +24,9 @@ call ale#linter#Define('c', { \ 'name': 'clang', \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#c#clang#GetExecutable', -\ 'command_callback': 'ale_linters#c#clang#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, +\ {'callback': 'ale_linters#c#clang#GetCommand'} +\ ], \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim index 4b241e37..98563952 100644 --- a/ale_linters/c/gcc.vim +++ b/ale_linters/c/gcc.vim @@ -8,15 +8,15 @@ function! ale_linters#c#gcc#GetExecutable(buffer) abort return ale#Var(a:buffer, 'c_gcc_executable') endfunction -function! ale_linters#c#gcc#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +function! ale_linters#c#gcc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer)) \ . ' -S -x c -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags \ . ale#Var(a:buffer, 'c_gcc_options') . ' -' endfunction @@ -24,6 +24,9 @@ call ale#linter#Define('c', { \ 'name': 'gcc', \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#c#gcc#GetExecutable', -\ 'command_callback': 'ale_linters#c#gcc#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, +\ {'callback': 'ale_linters#c#gcc#GetCommand'} +\ ], \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/ale_linters/cpp/clang.vim b/ale_linters/cpp/clang.vim index 105df821..e8d96187 100644 --- a/ale_linters/cpp/clang.vim +++ b/ale_linters/cpp/clang.vim @@ -8,15 +8,15 @@ function! ale_linters#cpp#clang#GetExecutable(buffer) abort return ale#Var(a:buffer, 'cpp_clang_executable') endfunction -function! ale_linters#cpp#clang#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +function! ale_linters#cpp#clang#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer)) \ . ' -S -x c++ -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags \ . ale#Var(a:buffer, 'cpp_clang_options') . ' -' endfunction @@ -24,6 +24,9 @@ call ale#linter#Define('cpp', { \ 'name': 'clang', \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable', -\ 'command_callback': 'ale_linters#cpp#clang#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, +\ {'callback': 'ale_linters#cpp#clang#GetCommand'}, +\ ], \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim index 40dffc98..577c9f79 100644 --- a/ale_linters/cpp/gcc.vim +++ b/ale_linters/cpp/gcc.vim @@ -8,15 +8,15 @@ function! ale_linters#cpp#gcc#GetExecutable(buffer) abort return ale#Var(a:buffer, 'cpp_gcc_executable') endfunction -function! ale_linters#cpp#gcc#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer)) \ . ' -S -x c++ -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags \ . ale#Var(a:buffer, 'cpp_gcc_options') . ' -' endfunction @@ -24,6 +24,9 @@ call ale#linter#Define('cpp', { \ 'name': 'g++', \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable', -\ 'command_callback': 'ale_linters#cpp#gcc#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, +\ {'callback': 'ale_linters#cpp#gcc#GetCommand'}, +\ ], \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/ale_linters/fish/fish.vim b/ale_linters/fish/fish.vim index 19158cb0..87ede29a 100644 --- a/ale_linters/fish/fish.vim +++ b/ale_linters/fish/fish.vim @@ -7,22 +7,53 @@ function! ale_linters#fish#fish#Handle(buffer, lines) abort " home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition " function foo " ^ - " <W> fish: Error while reading file .config/fish/functions/foo.fish - let l:pattern = '^.* (line \(\d\+\)): \(.*\)$' + " + " OR, patterns such as: + " + " Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'. + " /tmp/vLz620o/258/test.fish (line 2): if set -q SSH_CLIENT || set -q SSH_TTY + " ^ + " + " fish -n can return errors in either format. + let l:pattern = '^\(.* (line \(\d\+\)): \)\(.*\)$' + let l:column_pattern = '^ *\^' let l:output = [] + let l:column_offset = 0 + let l:last_line_with_message = '' + + for l:line in a:lines + " Look for error lines first. + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + if !empty(l:last_line_with_message) + let l:text = l:last_line_with_message + else + let l:text = l:match[3] + endif + + let l:column_offset = len(l:match[1]) + + let l:last_line_with_message = '' + call add(l:output, { + \ 'col': 0, + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:text, + \}) + else + " Look for column markers like ' ^' second. + " The column index will be set according to how long the line is. + let l:column_match = matchstr(l:line, l:column_pattern) - let l:i = 0 - while l:i < len(a:lines) - let l:match = matchlist(a:lines[l:i], l:pattern) - if len(l:match) && len(l:match[2]) - call add(l:output, { - \ 'col': len(a:lines[l:i + 2]), - \ 'lnum': str2nr(l:match[1]), - \ 'text': l:match[2], - \}) - endif - let l:i += 1 - endwhile + if !empty(l:column_match) && !empty(l:output) + let l:output[-1].col = len(l:column_match) - l:column_offset + let l:last_line_with_message = '' + else + let l:last_line_with_message = l:line + let l:column_offset = 0 + endif + endif + endfor return l:output endfunction diff --git a/ale_linters/go/gosimple.vim b/ale_linters/go/gosimple.vim index 8a4c01e1..dbdc3fcf 100644 --- a/ale_linters/go/gosimple.vim +++ b/ale_linters/go/gosimple.vim @@ -1,11 +1,15 @@ " Author: Ben Reedy <https://github.com/breed808> " Description: gosimple for Go files +function! ale_linters#go#gosimple#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) . ' gosimple .' +endfunction + call ale#linter#Define('go', { \ 'name': 'gosimple', \ 'executable': 'gosimple', -\ 'command': 'gosimple %s', -\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\ 'command_callback': 'ale_linters#go#gosimple#GetCommand', +\ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', \ 'lint_file': 1, \}) diff --git a/ale_linters/go/gotype.vim b/ale_linters/go/gotype.vim index 731f4c92..f4bb274e 100644 --- a/ale_linters/go/gotype.vim +++ b/ale_linters/go/gotype.vim @@ -1,23 +1,20 @@ " Author: Jelte Fennema <github-public@jeltef.nl> " Description: gotype for Go files -call ale#linter#Define('go', { -\ 'name': 'gotype', -\ 'output_stream': 'stderr', -\ 'executable': 'gotype', -\ 'command_callback': 'ale_linters#go#gotype#GetCommand', -\ 'callback': 'ale#handlers#unix#HandleAsError', -\}) - -"\ 'command': function! ale_linters#go#gotype#GetCommand(buffer) abort - let l:cur_file = expand('#' . a:buffer . ':p') - if l:cur_file =~# '_test\.go$' + if expand('#' . a:buffer . ':p') =~# '_test\.go$' return endif - let l:module_files = globpath(expand('#' . a:buffer . ':p:h'), '*.go', 0, 1) - let l:other_module_files = filter(l:module_files, 'v:val isnot# ' . ale#util#EscapeVim(l:cur_file) . ' && v:val !~# "_test\.go$"') - return 'gotype %t ' . join(map(l:other_module_files, 'ale#Escape(v:val)')) + return ale#path#BufferCdString(a:buffer) . ' gotype .' endfunction + +call ale#linter#Define('go', { +\ 'name': 'gotype', +\ 'output_stream': 'stderr', +\ 'executable': 'gotype', +\ 'command_callback': 'ale_linters#go#gotype#GetCommand', +\ 'callback': 'ale#handlers#go#Handler', +\ 'lint_file': 1, +\}) diff --git a/ale_linters/go/govet.vim b/ale_linters/go/govet.vim index aae5969d..edf9eb66 100644 --- a/ale_linters/go/govet.vim +++ b/ale_linters/go/govet.vim @@ -8,28 +8,11 @@ function! ale_linters#go#govet#GetCommand(buffer) abort return ale#path#BufferCdString(a:buffer) . ' go vet .' endfunction -function! ale_linters#go#govet#Handler(buffer, lines) abort - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? ?(.+)$' - let l:output = [] - let l:dir = expand('#' . a:buffer . ':p:h') - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), - \ '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('go', { \ 'name': 'go vet', \ 'output_stream': 'stderr', \ 'executable': 'go', \ 'command_callback': 'ale_linters#go#govet#GetCommand', -\ 'callback': 'ale_linters#go#govet#Handler', +\ 'callback': 'ale#handlers#go#Handler', \ 'lint_file': 1, \}) diff --git a/ale_linters/go/staticcheck.vim b/ale_linters/go/staticcheck.vim index ce9e6e38..a3464015 100644 --- a/ale_linters/go/staticcheck.vim +++ b/ale_linters/go/staticcheck.vim @@ -27,7 +27,7 @@ call ale#linter#Define('go', { \ 'name': 'staticcheck', \ 'executable': 'staticcheck', \ 'command_callback': 'ale_linters#go#staticcheck#GetCommand', -\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', \ 'lint_file': 1, \}) diff --git a/ale_linters/markdown/markdownlint.vim b/ale_linters/markdown/markdownlint.vim new file mode 100644 index 00000000..5c8af650 --- /dev/null +++ b/ale_linters/markdown/markdownlint.vim @@ -0,0 +1,11 @@ +" Author: Ty-Lucas Kelley <tylucaskelley@gmail.com> +" 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' +\ }) diff --git a/ale_linters/markdown/remark_lint.vim b/ale_linters/markdown/remark_lint.vim index 5b3b3d47..98dd0d7b 100644 --- a/ale_linters/markdown/remark_lint.vim +++ b/ale_linters/markdown/remark_lint.vim @@ -1,18 +1,24 @@ -" Author rhysd https://rhysd.github.io/ +" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr) " Description: remark-lint for Markdown files function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort " matches: ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint' - let l:pattern = '^ \+\(\d\+\):\(\d\+\) \(warning\|error\) \(.\+\)$' + " matches: ' 18:71-19:1 error Missing new line after list item list-item-spacing remark-lint', + let l:pattern = '^ \+\(\d\+\):\(\d\+\)\(-\(\d\+\):\(\d\+\)\)\? \(warning\|error\) \(.\+\)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { + let l:item = { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 0, - \ 'type': l:match[3] is# 'error' ? 'E' : 'W', - \ 'text': l:match[4], - \}) + \ 'type': l:match[6] is# 'error' ? 'E' : 'W', + \ 'text': l:match[7], + \} + if l:match[3] isnot# '' + let l:item.end_lnum = l:match[4] + 0 + let l:item.end_col = l:match[5] + 0 + endif + call add(l:output, l:item) endfor return l:output diff --git a/ale_linters/markdown/textlint.vim b/ale_linters/markdown/textlint.vim new file mode 100644 index 00000000..26458506 --- /dev/null +++ b/ale_linters/markdown/textlint.vim @@ -0,0 +1,9 @@ +" Author: tokida https://rouger.info, Yasuhiro Kiyota <yasuhiroki.duck@gmail.com> +" Description: textlint, a proofreading tool (https://textlint.github.io/) + +call ale#linter#Define('markdown', { +\ 'name': 'textlint', +\ 'executable_callback': 'ale#handlers#textlint#GetExecutable', +\ 'command_callback': 'ale#handlers#textlint#GetCommand', +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/ale_linters/po/msgfmt.vim b/ale_linters/po/msgfmt.vim index 60c25d30..578792bf 100644 --- a/ale_linters/po/msgfmt.vim +++ b/ale_linters/po/msgfmt.vim @@ -5,6 +5,6 @@ call ale#linter#Define('po', { \ 'name': 'msgfmt', \ 'executable': 'msgfmt', \ 'output_stream': 'stderr', -\ 'command': 'msgfmt --statistics %t', +\ 'command': 'msgfmt --statistics --output-file=- %t', \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/qml/qmllint.vim b/ale_linters/qml/qmllint.vim new file mode 100644 index 00000000..c2258a14 --- /dev/null +++ b/ale_linters/qml/qmllint.vim @@ -0,0 +1,29 @@ +" Author: pylipp (www.github.com/pylipp) +" Description: qmllint for QML files + +" Find lines like +" /home/foo_user42/code-base/qml/Screen.qml:11 : Expected token `}' +function! ale_linters#qml#qmllint#Handle(buffer, lines) abort + let l:pattern = '\v^[/_-a-zA-z0-9\. ]+:(\d+) : (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': 'E', + \} + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('qml', { +\ 'name': 'qmllint', +\ 'output_stream': 'stderr', +\ 'executable': 'qmllint', +\ 'command': 'qmllint %t', +\ 'callback': 'ale_linters#qml#qmllint#Handle', +\}) diff --git a/ale_linters/text/textlint.vim b/ale_linters/text/textlint.vim new file mode 100644 index 00000000..8fafdd7d --- /dev/null +++ b/ale_linters/text/textlint.vim @@ -0,0 +1,9 @@ +" Author: Yasuhiro Kiyota <yasuhiroki.duck@gmail.com> +" Description: textlint, a proofreading tool (https://textlint.github.io/) + +call ale#linter#Define('text', { +\ 'name': 'textlint', +\ 'executable_callback': 'ale#handlers#textlint#GetExecutable', +\ 'command_callback': 'ale#handlers#textlint#GetCommand', +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index f4b48169..6f94fbae 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -70,7 +70,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort \ : '' return ale#path#BufferCdString(a:buffer) - \ . ale_linters#typescript#tslint#GetExecutable(a:buffer) + \ . ale#Escape(ale_linters#typescript#tslint#GetExecutable(a:buffer)) \ . ' --format json' \ . l:tslint_config_option \ . l:tslint_rules_option |