diff options
author | Marcus Zanona <marcus@zanona.co> | 2017-11-09 09:49:44 -0200 |
---|---|---|
committer | Marcus Zanona <marcus@zanona.co> | 2017-11-09 10:39:39 -0200 |
commit | 732d8e3ed6deb1b16bf47e21ce1a823e5e23228b (patch) | |
tree | 304b1d14291bd493c262862c3d2985082ad11508 | |
parent | 8ef8a35462e9d3fbfe3fdf704e06ab957fb4ed7f (diff) | |
download | ale-732d8e3ed6deb1b16bf47e21ce1a823e5e23228b.zip |
Add support for linting less files with lessc
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | ale_linters/less/lessc.vim | 36 | ||||
-rw-r--r-- | doc/ale-less.txt | 11 | ||||
-rw-r--r-- | doc/ale.txt | 2 |
4 files changed, 50 insertions, 0 deletions
@@ -109,6 +109,7 @@ formatting. | JSON | [jsonlint](http://zaa.ch/jsonlint/), [prettier](https://github.com/prettier/prettier) | | Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions | | LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) | +| Less | [lessc](https://www.npmjs.com/package/less) | | LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) | | Lua | [luacheck](https://github.com/mpeterv/luacheck) | | Mail | [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) | diff --git a/ale_linters/less/lessc.vim b/ale_linters/less/lessc.vim new file mode 100755 index 00000000..3f6e265f --- /dev/null +++ b/ale_linters/less/lessc.vim @@ -0,0 +1,36 @@ +" 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_options', '') + +function! ale_linters#less#lessc#GetCommand(buffer) abort + return 'lessc' + \ . ' --no-color --lint ' + \ . ale#Var(a:buffer, 'less_lessc_options') + \ . ' %t' +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', +\}) diff --git a/doc/ale-less.txt b/doc/ale-less.txt index a6b5998e..cac9c9af 100644 --- a/doc/ale-less.txt +++ b/doc/ale-less.txt @@ -3,6 +3,17 @@ ALE Less Integration *ale-less-options* =============================================================================== +lessc *ale-less-lessc* + +g:ale_less_lessc_options *g:ale_less_lessc_options* + *b:ale_less_lessc_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lessc. + + +=============================================================================== prettier *ale-less-prettier* See |ale-javascript-prettier| for information about the available options. diff --git a/doc/ale.txt b/doc/ale.txt index 2ee2c2d7..ffe7ac7e 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -105,6 +105,7 @@ CONTENTS *ale-contents* latex.................................|ale-latex-options| write-good..........................|ale-latex-write-good| less..................................|ale-less-options| + lessc...............................|ale-less-lessc-options| prettier............................|ale-less-prettier| llvm..................................|ale-llvm-options| llc.................................|ale-llvm-llc| @@ -293,6 +294,7 @@ Notes: * JSON: `jsonlint`, `prettier` * Kotlin: `kotlinc`, `ktlint` * LaTeX (tex): `chktex`, `lacheck`, `proselint`, `write-good` +* Less: `lessc` * LLVM: `llc` * Lua: `luacheck` * Mail: `proselint`, `vale` |