This post originated from an RSS feed registered with Java Buzz
by Tim Vernum.
Original Post: Vim syntax highlighting for LESS
Feed Title: A word used to describe something
Feed URL: http://blog.adjective.org/feed/category/Development/rss2
Feed Description: Tim's random musings on software development, java, jetty and other such frivolities.
Groenewge's syntax file on
github seems to be the best version. It makes use of any existing CSS
syntax files you have including the one that ships with Vim.
However, because the LESS syntax is more rich than pure CSS, this syntax
file shows up an ambiguity in the default CSS syntax file.
Vim's css.vim
(as at rev d3cf98aa1619) has font as a
cssTagName and font-size / font-family /
etc as cssFontProp. When you have a pure css file, these
match fine. But when you load the less syntax. they become ambiguous (because
less allows things in different places)
So, you find that BODY { font-size: 12pt; } will match "font" as a tag (and
"-size" as text), rather than "font-size" as a property.
The fix is to make a small modification to css.vim to only match "font" as a
whole-word.
I've created an
issue on the google code site, and included a patch there. So, if you're
using LESS + VIM, and want syntax highlighting, then it's probably worth
installing that patch.
I also found that if you have hail2u's CCS3 syntax installed,
then LESS parametric mixins don't highlight correctly. This is due to an
overzealous media type rule in css3-mediaqueries.vim. I put in a
quick fix by commenting out the first rule in that file (I don't make much use
of media types anyway)