diff options
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/cpp/cpplint.vim | 15 | ||||
-rw-r--r-- | ale_linters/javascript/eslint.vim | 18 |
2 files changed, 30 insertions, 3 deletions
diff --git a/ale_linters/cpp/cpplint.vim b/ale_linters/cpp/cpplint.vim new file mode 100644 index 00000000..0f43996b --- /dev/null +++ b/ale_linters/cpp/cpplint.vim @@ -0,0 +1,15 @@ +" Author: Dawid Kurek https://github.com/dawikur +" Description: cpplint for cpp files + +if !exists('g:ale_cpp_cpplint_options') + let g:ale_cpp_cpplint_options = '' +endif + +call ale#linter#Define('cpp', { +\ 'name': 'cpplint', +\ 'output_stream': 'stderr', +\ 'executable': 'cpplint', +\ 'command': 'cpplint %s', +\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', +\ 'lint_file': 1, +\}) diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim index d5e51acb..f1c3bb01 100644 --- a/ale_linters/javascript/eslint.vim +++ b/ale_linters/javascript/eslint.vim @@ -39,6 +39,13 @@ function! ale_linters#javascript#eslint#GetCommand(buffer) abort \ . ' -f unix --stdin --stdin-filename %s' endfunction +let s:col_end_patterns = [ +\ '\vParsing error: Unexpected token (.+) ', +\ '\v''(.+)'' is not defined.', +\ '\v%(Unexpected|Redundant use of) [''`](.+)[''`]', +\ '\vUnexpected (console) statement', +\] + function! ale_linters#javascript#eslint#Handle(buffer, lines) abort let l:config_error_pattern = '\v^ESLint couldn''t find a configuration file' \ . '|^Cannot read config file' @@ -77,13 +84,18 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines) abort let l:text .= ' [' . l:match[4] . ']' endif - call add(l:output, { - \ 'bufnr': a:buffer, + let l:obj = { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 0, \ 'text': l:text, \ 'type': l:type ==# 'Warning' ? 'W' : 'E', - \}) + \} + + for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns) + let l:obj.end_col = l:obj.col + len(l:col_match[1]) - 1 + endfor + + call add(l:output, l:obj) endfor return l:output |