]> git.madduck.net Git - etc/vim.git/blob - ale_linters/pug/puglint.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:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / pug / puglint.vim
1 " Author: w0rp - <devw0rp@gmail.com>
2 " Description: pug-lint for checking Pug/Jade files.
3
4 call ale#Set('pug_puglint_options', '')
5 call ale#Set('pug_puglint_executable', 'pug-lint')
6 call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0))
7
8 function! s:FindConfig(buffer) abort
9     for l:filename in [
10     \   '.pug-lintrc',
11     \   '.pug-lintrc.js',
12     \   '.pug-lintrc.json',
13     \   'package.json',
14     \]
15         let l:config = ale#path#FindNearestFile(a:buffer, l:filename)
16
17         if !empty(l:config)
18             return l:config
19         endif
20     endfor
21
22     return ''
23 endfunction
24
25 function! ale_linters#pug#puglint#GetCommand(buffer) abort
26     let l:options = ale#Var(a:buffer, 'pug_puglint_options')
27     let l:config = s:FindConfig(a:buffer)
28
29     return '%e' . ale#Pad(l:options)
30     \   . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
31     \   . ' -r inline %t'
32 endfunction
33
34 function! ale_linters#pug#puglint#Handle(buffer, lines) abort
35     for l:line in a:lines[:10]
36         if l:line =~# '^SyntaxError: '
37             return [{
38             \   'lnum': 1,
39             \   'text': 'puglint configuration error (type :ALEDetail for more information)',
40             \   'detail': join(a:lines, "\n"),
41             \}]
42         endif
43     endfor
44
45     return ale#handlers#unix#HandleAsError(a:buffer, a:lines)
46 endfunction
47
48 call ale#linter#Define('pug', {
49 \   'name': 'puglint',
50 \   'executable': {b -> ale#path#FindExecutable(b, 'pug_puglint', [
51 \       'node_modules/.bin/pug-lint',
52 \   ])},
53 \   'output_stream': 'stderr',
54 \   'command': function('ale_linters#pug#puglint#GetCommand'),
55 \   'callback': 'ale_linters#pug#puglint#Handle',
56 \})