Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Snippets defined in Emmet.sublime-settings, are not loaded #16

Closed
sergeche opened this Issue · 16 comments

5 participants

@sergeche
Owner

Check if data defined in settings is loaded correctly.

@sergeche sergeche was assigned
@GreLI

BTW, it's true. I haven't figured if it was I'm doing wrong.

@remybach

I'm getting this issue as well. Additionally, whenever I try to update the Emmet.sublime-settings file, Sublime force closes on me (in OSX 10.7.4).

@sergeche
Owner

@remybach are you using the latest repo version of Emmet? I’ve updated PyV8 binary a few days ago that should solve this issue.

@remybach

I only installed it this morning :/

@sergeche
Owner

Does it shows you crash report? If so, can you send it to me?

@remybach

Good thing it's a repeatable issue... here's the entire crash report: http://pastebin.com/RxB5KiqX

@sergeche
Owner

I was able to catch plugin crashes, looks like it’s PyV8 issue. I’ve filled ticket for PyV8 author: http://code.google.com/p/pyv8/issues/detail?id=135

But I can’t confirm that snippets are not loaded from Emmet.sublime-settings file. Can you post an example of your Emmet.sublime-settings with un-loaded snippets?

@remybach

My current Emmet.sublime-settings file (in ~/Library/Application Support/Sublime Text 2/Packages/User) looks as follows:

{
    "auto_id_class": true,
    "css": {
        "filters": "html"
    }
}

The filters bit is me trying to stop sublime from putting spaces after the colons in CSS. I've done a quick scan through the source, and what I've put seems to be the default, yet it's still adding spaces for me. This one might just be me doing it wrong.

The auto_id_class, however, definitely isn't working.

@sergeche
Owner

OK, seems there’s a small misunderstanding on preferences :)

  • There are two preferences file: Preferences.sublime-settings and Emmet.sublime-settings. The first one is used by ST2 internally to modify ST2 core text preferences, look & feel etc. Settings defined it this file are loaded on editor start-up and can be used as context options for key handlers. The auto_id_class option is used as context option for # and . characters so this setting must be defined in Preferences.sublime-settings in your Users dir.

  • The Emmet toolkit is highly configurable and many aspects can be configured by user. To separate data that should be loaded into different places of Emmet, user data must be splitted into sections. The main sections are snippets (user snippets and abbreviations) and preferences (modify Emmet behaviour). This data is plugin-specific and should be defined in Emmet.sublime-settings file, which is loaded by plugin itself on demand.

Back to your problem: snippets should be defined in snippets section of Emmet.sublime-settings. The settings structure is following (refer to https://github.com/sergeche/zen-coding/blob/v0.7.1/snippets.json as example):

...
"snippets": {
    "css": {     // syntax name where snippets should be added
        "snippets": {    // data type: "snippets" or "abbreviations"
            ...
        }
    }
}

The first argument of prefs.define method is option name, option value is the second. There’s a special module preferences of Emmet that stores preferences and provides methods to retrieve and override preferences values. You can override this preferences with preferences section of Emmet.sublime-settings file. In your case, it may look like this:

"preferences": {
    "css.valueSeparator": ":"
}

Summing up, your Emmet.sublime-settings should look like this (as shown in example):

{
    "snippets": {
        "css": {
            "snippets": {
                // put snippets definition here
            }
        }
    },
    "preferences": {
        "css.valueSeparator": ":"
    }
}
@remybach

That is amazingly helpful! Thank you so much!

@sergeche
Owner

So, is this works for everyone? Can I close this issue?

@remybach

Yeah, I'm happy with that! Thanks :)

@sergeche sergeche closed this
@sergeche sergeche referenced this issue
Closed

Custom snippets #41

@demun

Let me know how to install Windows from Emmet

@sergeche
Owner

@demun Emmet can’t install Windows :)
All installation instructions are described on front page.

@pablodelriob

Or use

"disable_tab_abbreviations": false

Trying to change to "false" I thought it would work, and actually worked! at least for me.

@pablodelriob

But sometimes, it shows me this error

A plugin (emmet-plugin) may be making Sublime Text unresponsive by taking too long (0.021000s) in its on_query_contextt callback

This message can be disabled via the detect_slow_plugins setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.