ale/ale_linters/pug/puglint.vim

43 lines
1.2 KiB
VimL
Raw Normal View History

2016-10-07 21:16:29 +00:00
" Author: w0rp - <devw0rp@gmail.com>
" Description: pug-lint for checking Pug/Jade files.
call ale#Set('pug_puglint_options', '')
call ale#Set('pug_puglint_executable', 'pug-lint')
call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0))
function! s:FindConfig(buffer) abort
for l:filename in [
\ '.pug-lintrc',
\ '.pug-lintrc.js',
\ '.pug-lintrc.json',
\ 'package.json',
\]
let l:config = ale#path#FindNearestFile(a:buffer, l:filename)
if !empty(l:config)
return l:config
endif
endfor
return ''
endfunction
function! ale_linters#pug#puglint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'pug_puglint_options')
let l:config = s:FindConfig(a:buffer)
return '%e' . ale#Pad(l:options)
\ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
\ . ' -r inline %t'
endfunction
call ale#linter#Define('pug', {
2016-10-07 21:16:29 +00:00
\ 'name': 'puglint',
\ 'executable_callback': ale#node#FindExecutableFunc('pug_puglint', [
\ 'node_modules/.bin/pug-lint',
\ ]),
2016-10-07 21:16:29 +00:00
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#pug#puglint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError',
2016-10-07 21:16:29 +00:00
\})