summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-03-22 15:20:25 +0000
committerGitHub <noreply@github.com>2018-03-22 15:20:25 +0000
commitec5750f57b6b98b46cf041f32bcc5d890f3e7e37 (patch)
tree32c5926ba28ee6e6d3930eb65ae2d9adf5fdc27d
parentc525f49f09876a77166fa18f8e844886fa968fee (diff)
parent87217ae347f71836c2e47b84dfbf26b1f2630d94 (diff)
downloadale-ec5750f57b6b98b46cf041f32bcc5d890f3e7e37.zip
Merge pull request #1441 from adrigzr/bugfix-1207-remark-lint-ranges
Handle ranges for the remark linter #1207
-rw-r--r--ale_linters/markdown/remark_lint.vim18
-rw-r--r--test/handler/test_remark_lint_handler.vader11
2 files changed, 22 insertions, 7 deletions
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/test/handler/test_remark_lint_handler.vader b/test/handler/test_remark_lint_handler.vader
index f61da199..0794d51c 100644
--- a/test/handler/test_remark_lint_handler.vader
+++ b/test/handler/test_remark_lint_handler.vader
@@ -19,12 +19,21 @@ Execute(Warning and error messages should be handled correctly):
\ 'type': 'E',
\ 'text': 'Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
\ },
+ \ {
+ \ 'lnum': 18,
+ \ 'col': 71,
+ \ 'end_lnum': 19,
+ \ 'end_col': 1,
+ \ 'type': 'E',
+ \ 'text': 'Missing new line after list item list-item-spacing remark-lint',
+ \ },
\ ],
\ ale_linters#markdown#remark_lint#Handle(1, [
\ 'foo.md',
\ ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint',
\ ' 3:5 error Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
+ \ ' 18:71-19:1 error Missing new line after list item list-item-spacing remark-lint',
\ '',
\ '⚠ 1 warnings',
- \ '✘ 1 errors',
+ \ '✘ 2 errors',
\])