简体   繁体   中英

finding vim efm for csslint messages

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.

您需要使用双反斜杠来转义Vim的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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM