2017-11-09 15:40:13 +00:00
|
|
|
" Author: zanona <https://github.com/zanona>
|
2017-11-09 11:49:44 +00:00
|
|
|
" Description: This file adds support for checking Less code with lessc.
|
|
|
|
|
|
|
|
call ale#Set('less_lessc_options', '')
|
|
|
|
|
|
|
|
function! ale_linters#less#lessc#GetCommand(buffer) abort
|
2017-11-09 21:52:08 +00:00
|
|
|
return 'lessc'
|
2017-11-09 15:45:14 +00:00
|
|
|
\ . ' --no-color --lint --include-path=' . expand('%:p:h')
|
2017-11-09 15:39:38 +00:00
|
|
|
\ . ' ' . ale#Var(a:buffer, 'less_lessc_options')
|
2017-11-09 15:45:14 +00:00
|
|
|
\ . ' -'
|
2017-11-09 11:49:44 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#less#lessc#Handle(buffer, lines) abort
|
|
|
|
" Matches patterns like the following:
|
|
|
|
let l:pattern = '^\(\w\+\): \(.\{-}\) in \(.\{-}\) on line \(\d\+\), column \(\d\+\):$'
|
|
|
|
let l:output = []
|
|
|
|
|
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': l:match[4] + 0,
|
|
|
|
\ 'col': l:match[5] + 0,
|
|
|
|
\ 'text': l:match[2],
|
|
|
|
\ 'type': 'E',
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('less', {
|
|
|
|
\ 'name': 'lessc',
|
|
|
|
\ 'executable': 'lessc',
|
|
|
|
\ 'output_stream': 'stderr',
|
|
|
|
\ 'command_callback': 'ale_linters#less#lessc#GetCommand',
|
|
|
|
\ 'callback': 'ale_linters#less#lessc#Handle',
|
|
|
|
\})
|