Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit c779dbb

Browse files
committed
Checker markdown/remark_lint: cleanup.
1 parent 8e7a30b commit c779dbb

File tree

4 files changed

+84
-9
lines changed

4 files changed

+84
-9
lines changed

autoload/syntastic/preprocess.vim

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,49 @@ function! syntastic#preprocess#rparse(errors) abort " {{{2
388388
return out
389389
endfunction " }}}2
390390

391+
function! syntastic#preprocess#remark_lint(errors) abort " {{{2
392+
let out = []
393+
let fname = expand('%', 1)
394+
395+
for err in a:errors
396+
if err =~# '\m^\f\+$'
397+
let fname = err
398+
399+
elseif err =~# '\v^\s+\d+:\d+\s+%(warning|error)\s.*remark-lint$'
400+
let parts = matchlist(err, '\v^\s+(\d+):(\d+)\s+([ew])\S+\s+(.{-})\s+(\S+)\s+remark-lint$')
401+
if len(parts) >6
402+
let line = str2nr(parts[1])
403+
let col = str2nr(parts[2])
404+
let type = parts[3]
405+
let message = parts[4] . ' [' . parts[5] . ']'
406+
call add(out, join([fname, type, line, col, message], ':'))
407+
else
408+
call syntastic#log#warn('checker markdown/remark_lint: unrecognized error item ' . string(err))
409+
endif
410+
411+
elseif err =~# '\v^\s+\d+:\d+-\d+:\d+\s+%(warning|error)\s.*remark-lint$'
412+
let parts = matchlist(err, '\v^\s+(\d+):(\d+)-(\d+):(\d+)\s+([ew])\S+\s+(.{-})\s+(\S+)\s+remark-lint$')
413+
if len(parts) >8
414+
let line1 = str2nr(parts[1])
415+
let col1 = str2nr(parts[2])
416+
let line2 = str2nr(parts[3])
417+
let col2 = str2nr(parts[4]) - 1
418+
let type = parts[5]
419+
let message = parts[6] . ' [' . parts[7] . ']'
420+
if line1 == line2
421+
call add(out, join([fname, type, line1, col1, col2, message], ':'))
422+
else
423+
call add(out, join([fname, type, line1, col1, message], ':'))
424+
endif
425+
else
426+
call syntastic#log#warn('checker markdown/remark_lint: unrecognized error item ' . string(err))
427+
endif
428+
endif
429+
endfor
430+
431+
return out
432+
endfunction " }}}2
433+
391434
function! syntastic#preprocess#scss_lint(errors) abort " {{{2
392435
let errs = join(a:errors, '')
393436
if errs ==# ''

doc/syntastic-checkers.txt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,7 +4090,8 @@ The following checkers are available for Markdown (filetype "markdown"):
40904090

40914091
1. Markdown lint tool.......|syntastic-markdown-mdl|
40924092
2. proselint................|syntastic-markdown-proselint|
4093-
3. textlint.................|syntastic-markdown-textlint|
4093+
3. remark-lint..............|syntastic-markdown-remark_lint|
4094+
4. textlint.................|syntastic-markdown-textlint|
40944095

40954096
------------------------------------------------------------------------------
40964097
1. Markdown lint tool *syntastic-markdown-mdl*
@@ -4148,7 +4149,29 @@ See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
41484149
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
41494150

41504151
------------------------------------------------------------------------------
4151-
3. textlint *syntastic-markdown-textlint*
4152+
3. remark-lint *syntastic-markdown-remark_lint*
4153+
4154+
Name: remark_lint
4155+
Maintainer: Tim Carry <tim@pixelastic.com>
4156+
4157+
"remark-lint" is a code style linter for Markdown files. See the project's
4158+
page at GitHub for details:
4159+
4160+
https://github.com/remarkjs/remark-lint
4161+
4162+
Note~
4163+
4164+
Syntastic can't check whether "remark-lint" is installed properly beyond the
4165+
existence of an executable named "remark". Please make sure "remark-lint" is
4166+
installed and working properly before attempting to use it with syntastic.
4167+
4168+
Checker options~
4169+
4170+
This checker is initialised using the "makeprgBuild()" function and thus it
4171+
accepts the standard options described at |syntastic-config-makeprg|.
4172+
4173+
------------------------------------------------------------------------------
4174+
4. textlint *syntastic-markdown-textlint*
41524175

41534176
Name: textlint
41544177
Maintainer: LCD 47 <lcd047@gmail.com>

plugin/syntastic.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if has('reltime')
1919
lockvar! g:_SYNTASTIC_START
2020
endif
2121

22-
let g:_SYNTASTIC_VERSION = '3.9.0-9'
22+
let g:_SYNTASTIC_VERSION = '3.9.0-14'
2323
lockvar g:_SYNTASTIC_VERSION
2424

2525
" Sanity checks {{{1

syntax_checkers/markdown/remark_lint.vim

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,27 @@ let s:save_cpo = &cpo
2020
set cpo&vim
2121

2222
function! SyntaxCheckers_markdown_remark_lint_GetLocList() dict
23-
let makeprg = self.makeprgBuild({
24-
\'args_before': '--quiet --no-stdout --no-color' })
23+
let makeprg = self.makeprgBuild({ 'args_before': '--quiet --no-stdout --no-color' })
2524

2625
let errorformat =
27-
\ '%\s%#%l:%c%\s%#%tarning %m remark-lint,' .
28-
\ '%\s%#%l:%c-%.%#%\s%#%tarning %m remark-lint'
26+
\ '%f:%t:%l:%c:%n:%m,' .
27+
\ '%f:%t:%l:%c:%m'
2928

30-
return SyntasticMake({
29+
let loclist = SyntasticMake({
3130
\ 'makeprg': makeprg,
3231
\ 'errorformat': errorformat,
33-
\ 'defaults': {'bufnr': bufnr('')},
32+
\ 'preprocess': 'remark_lint',
33+
\ 'subtype': 'Style',
3434
\ 'returns': [0] })
35+
36+
for e in loclist
37+
if get(e, 'col', 0) && get(e, 'nr', 0)
38+
let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['nr'] + 1) . 'c'
39+
let e['nr'] = 0
40+
endif
41+
endfor
42+
43+
return loclist
3544
endfunction
3645

3746
call g:SyntasticRegistry.CreateAndRegisterChecker({

0 commit comments

Comments
 (0)