]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/markdown/remark_lint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / ale_linters / markdown / remark_lint.vim
1 scriptencoding utf-8
2 " Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
3 " Description: remark-lint for Markdown files
4 call ale#Set('markdown_remark_lint_executable', 'remark')
5 call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0))
6 call ale#Set('markdown_remark_lint_options', '')
7
8 function! ale_linters#markdown#remark_lint#GetCommand(buffer) abort
9     let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options')
10
11     return '%e' . ale#Pad(l:options) . ' --no-stdout --no-color'
12 endfunction
13
14 function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
15     " matches: '  1:4  warning  Incorrect list-item indent: add 1 space  list-item-indent  remark-lint'
16     " matches: '  18:71-19:1  error  Missing new line after list item  list-item-spacing  remark-lint',
17     let l:pattern = '^ \+\(\d\+\):\(\d\+\)\(-\(\d\+\):\(\d\+\)\)\?  \(warning\|error\)  \(.\+\)$'
18     let l:output = []
19
20     for l:match in ale#util#GetMatches(a:lines, l:pattern)
21         let l:item = {
22         \   'lnum': l:match[1] + 0,
23         \   'col': l:match[2] + 0,
24         \   'type': l:match[6] is# 'error' ? 'E' : 'W',
25         \   'text': l:match[7],
26         \}
27
28         if l:match[3] isnot# ''
29             let l:item.end_lnum = l:match[4] + 0
30             let l:item.end_col = l:match[5] + 0
31         endif
32
33         call add(l:output, l:item)
34     endfor
35
36     return l:output
37 endfunction
38
39 call ale#linter#Define('markdown', {
40 \   'name': 'remark_lint',
41 \   'aliases': ['remark-lint'],
42 \   'executable': {b -> ale#path#FindExecutable(b, 'markdown_remark_lint', [
43 \       'node_modules/.bin/remark',
44 \   ])},
45 \   'command': function('ale_linters#markdown#remark_lint#GetCommand'),
46 \   'callback': 'ale_linters#markdown#remark_lint#Handle',
47 \   'output_stream': 'stderr',
48 \})