简体   繁体   English

查找csslint消息的vim efm

[英]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. 对于新发布的csslint,我想尝试将其挂接到vim作为.css文件的makefile。 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: 我在quickfix窗口中得到以下输出:

|| 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的格式为:

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? 有人看到我的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 . 我只是使用CSS Lint将CSS语法检查器提交给Syntastic插件 Just fetch the latest Syntastic version from GitHub, and install CSS Lint CLI tool , and you'll be on your way. 只需从GitHub上获取最新的Syntastic版本 ,然后安装CSS Lint CLI工具 ,您就可以开始使用。

Please note that CSS Lint's warning/error format is pretty incosistent, but the plugin I wrote handles it pretty well. 请注意,CSS Lint的警告/错误格式相当吸引人,但是我编写的插件可以很好地处理它。 I expect it to improve in the future. 我希望将来会有所改善。

Working with vim's errorformat is a veritable nightmare. 使用vim的errorformat确实是一场噩梦。 Usually I re-write lint output in shell for vim, though with the --format=compact switch it's thankfully workable. 通常我会在shell中为vim重新编写lint输出,尽管使用--format=compact开关还是可以的。

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 来源: https : //github.com/kaihendry/vim-html5/blob/master/ftplugin/css.vim

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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