Frage

With the newly released csslint I wanted to try to hook it into vim as my makefile for .css files. I'm having a hard time getting the multi-line error format working for the output.

My best result so far is:

au BufRead *.css set makeprg=csslint\ %
au BufRead *.css set errorformat=%A%f:,%C%n:\ warning\ at\ line\ %l\,\ col\ %c,%C%m,%C%.%#,%C%.%#

That doesn't get the line/column numbers right though. I'm getting this output in my quickfix window:

|| csslint: There are 33 errors and warnings in bookie.css.
|| 
bookie.css||  1: warning Too many font-size declarations (13), abstraction needed.
bookie.css||  2: warning at line 3, col 3 Rule is empty. BODY {
bookie.css||  3: warning at line 12, col 12 Values of 0 shouldn't have units specified. padding: .5em 0em;
bookie.css||  4: warning at line 13, col 13 Values of 0 shouldn't have units specified. margin: 0em;
...

The format from csslint is:

csslint: There are 33 errors and warnings in bookie.css.

bookie.css:
1: warning
Too many font-size declarations (13), abstraction needed.

bookie.css:
2: warning at line 3, col 3
Rule is empty.
BODY {

Anyone see what's wrong with my efm? Or have something that might work? I'm trying not to go the route of writing another parse script to clean up the format. Thanks for the help.

War es hilfreich?

Lösung

You need to use a double backslash to escape commas in Vim's errorformat.

Andere Tipps

I just commited a CSS syntax-checker to Syntastic plugin, using CSS Lint. Just fetch the latest Syntastic version from GitHub, and install CSS Lint CLI tool, and you'll be on your way.

Please note that CSS Lint's warning/error format is pretty incosistent, but the plugin I wrote handles it pretty well. I expect it to improve in the future.

Working with vim's errorformat is a veritable nightmare. Usually I re-write lint output in shell for vim, though with the --format=compact switch it's thankfully workable.

set makeprg=csslint\ --format=compact\ %
set errorformat=%f:\ line\ %l\\,\ col\ \%c\\,\ %m

Source: https://github.com/kaihendry/vim-html5/blob/master/ftplugin/css.vim

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top