mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Removed syntastic and replaced it with ale
Read more here: https://github.com/w0rp/ale
This commit is contained in:
56
sources_non_forked/ale/ale_linters/less/lessc.vim
Normal file
56
sources_non_forked/ale/ale_linters/less/lessc.vim
Normal file
@ -0,0 +1,56 @@
|
||||
" Author: zanona <https://github.com/zanona>, w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for checking Less code with lessc.
|
||||
|
||||
call ale#Set('less_lessc_executable', 'lessc')
|
||||
call ale#Set('less_lessc_options', '')
|
||||
call ale#Set('less_lessc_use_global', 0)
|
||||
|
||||
function! ale_linters#less#lessc#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'less_lessc', [
|
||||
\ 'node_modules/.bin/lessc',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#less#lessc#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#less#lessc#GetExecutable(a:buffer)
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
let l:options = ale#Var(a:buffer, 'less_lessc_options')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' --no-color --lint'
|
||||
\ . ' --include-path=' . ale#Escape(l:dir)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#less#lessc#Handle(buffer, lines) abort
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
" 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)
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'col': l:match[5] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'type': 'E',
|
||||
\}
|
||||
|
||||
if l:match[3] isnot# '-'
|
||||
let l:item.filename = ale#path#GetAbsPath(l:dir, l:match[3])
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('less', {
|
||||
\ 'name': 'lessc',
|
||||
\ 'executable_callback': 'ale_linters#less#lessc#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#less#lessc#GetCommand',
|
||||
\ 'callback': 'ale_linters#less#lessc#Handle',
|
||||
\ 'output_stream': 'stderr',
|
||||
\})
|
27
sources_non_forked/ale/ale_linters/less/stylelint.vim
Normal file
27
sources_non_forked/ale/ale_linters/less/stylelint.vim
Normal file
@ -0,0 +1,27 @@
|
||||
" Author: diartyz <diartyz@gmail.com>, w0rp <devw0rp@gmail.com>
|
||||
|
||||
call ale#Set('less_stylelint_executable', 'stylelint')
|
||||
call ale#Set('less_stylelint_options', '')
|
||||
call ale#Set('less_stylelint_use_global', 0)
|
||||
|
||||
function! ale_linters#less#stylelint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'less_stylelint', [
|
||||
\ 'node_modules/.bin/stylelint',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#less#stylelint#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#less#stylelint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'less_stylelint_options')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('less', {
|
||||
\ 'name': 'stylelint',
|
||||
\ 'executable_callback': 'ale_linters#less#stylelint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#less#stylelint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
|
||||
\})
|
Reference in New Issue
Block a user