开发者

finding vim efm for csslint messages

开发者 https://www.devze.com 2023-03-13 18:56 出处:网络
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.

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'开发者_Go百科m trying not to go the route of writing another parse script to clean up the format. Thanks for the help.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号