LESS support

108 views
Skip to first unread message

IschaGast

unread,
Jul 4, 2012, 2:46:29 AM7/4/12
to zen-c...@googlegroups.com
I am a big fan of zencoding but it looks like there is no LESS support in Sublime Text, is there a way to get this working?

Sergey Chikuyonok

unread,
Jul 4, 2012, 4:01:53 AM7/4/12
to zen-c...@googlegroups.com
The simplest solution is to modify zencoding/interface/editor.py file.
You should update get_syntax() method (line 168) so it matches LESS scope but returns it as CSS. 

This method may look like this:

def get_syntax(self):
    """
    Returns current editor's syntax mode
    @return: str
    """
    view = active_view()
    scope = view.syntax_name(view.sel()[0].begin())
    default_type = 'html'
    doc_type = None

    try:
        if 'xsl' in scope:
            doc_type = 'xsl'
        else:
            doc_type = re.findall(r'\bhtml|js|less|css|xml|haml\b', scope)[0]
            # Sublime has back to front scopes ....
    except:
        doc_type = default_type

    if doc_type == 'less':
        # serve LESS documents as CSS
        doc_type = 'css'

    if not doc_type: doc_type = default_type
    return doc_type

___________________________________________
Сергей Чикуёнок
http://chikuyonok.ru
serg...@gmail.com

jakethesnake

unread,
Jul 11, 2012, 7:44:20 AM7/11/12
to zen-c...@googlegroups.com
Hi there,

Is there a way to add Zen coding support to LESS files with Espresso for mac? I am also looking to see if this is supported within PHPstorm software also?

Thanks in advance

Sergey Chikuyonok

unread,
Jul 11, 2012, 7:53:10 AM7/11/12
to zen-c...@googlegroups.com
It’s pretty hard right now: you have to modify minified JS file and update getSyntax() method of ZenEditor object in order to detect and handle LESS syntax.
I’m working on new Zen Coding version with Espresso developers and I think new version will feature basic LESS support.

PHPStopm plugin is developed by JetBrains team from scratch so you’d better ask them.

___________________________________________
Сергей Чикуёнок
http://chikuyonok.ru
serg...@gmail.com

jakethesnake

unread,
Jul 11, 2012, 7:58:55 AM7/11/12
to zen-c...@googlegroups.com
Wow what a speedy reply!

Never used Google groups before, but this is great thanks! Yes I had a look at the minified js file but it looked a bit too much. Thought it would be a simple thing like adding a ".less" next to the ".css" and ".html" in a settings file.

If you have something sorted for now, perhaps you could send me files that I could replace within my TEA of Espresso package folder?
-Its fine if you dont.

Thanks for your help thus far!
-Jake

Sergey Chikuyonok

unread,
Jul 11, 2012, 8:04:57 AM7/11/12
to zen-c...@googlegroups.com
In minified zen.js file, find ZenEditor.prototype.getSyntax function. The first variable is a map of Espresso syntax selectors and Zen Coding’s syntax and looks like this:
var c={"css, css *":"css","xsl, xsl *":"xsl","xml, xml *":"xml","haml, haml *":"haml"};

Try to add LESS syntax and map it to Zen Coding’s CSS syntax:
var c={"less, less *": "css", "css, css *":"css","xsl, xsl *":"xsl","xml, xml *":"xml","haml, haml *":"haml"};

___________________________________________
Сергей Чикуёнок
http://chikuyonok.ru
serg...@gmail.com

On Wednesday, July 11, 2012 at 3:44 PM, jakethesnake wrote:

jakethesnake

unread,
Jul 11, 2012, 8:16:17 AM7/11/12
to zen-c...@googlegroups.com
yes!! that worked!

Thank you so much!! you are the Zen master!! =)
Reply all
Reply to author
Forward
0 new messages